This topic contains 6 replies, has 0 voices, and was last updated by chanarbon 8 years ago.

  • Author
    Posts
  • #6601

    ARoberts18

    Hey,

    So I’m trying to display a custom field (custrecord…) via the PHP Toolkit. It’s the latest version. I copied this from SuiteAnswers and it works absolutely fine.

    baseRef = new CustomRecordRef();

    $request->baseRef->internalId = “58”;

    $request->baseRef->typeId = “122”; // Internal id of the Custom Record Type

    $getResponse = $service->get($request);

    if (!$getResponse->readResponse->status->isSuccess) {

    echo “GET ERROR”;

    } else {

    $custrec = $getResponse->readResponse->record;

    echo “GET SUCCESS!
    “;

    echo “Record Name: “. $custrec->name . ”
    “;

    echo “Internal Id: “. $custrec->internalId . ”
    “;

    }

    ?>

    The result is on my webpage:

    GET SUCCESS!

    Record Name: GVSM58

    Internal Id: 58

    This is perfect, the results are right. Now I want to display a custom field value on the page, e.g. custrecord100, which has the field value of “Donkey”. No matter what I do, it just won’t show. I’ve looked at the suiteanswer guides and tried to replicate what they have there, but I cannot get it to show. It would be so much simpler if it was just $custrec->custrecord100!

    Can someone tell me what the correct way of getting the field value is!

    Much appreciated.
    This is a cached copy. Click here to see the original post.

  • #6602

    chanarbon

    Hi @ARoberts18

    From the $custrec response of the web services call, it normally returns a list of fields like list of custom fields which is customFieldList and the custom fields are enclosed in there. Would it be possible for you to try $custrec->customFieldList->custrecord100. Also, a quick var_dump() of $custrec wouldn’t be that hard to view the values in the object

  • #6603

    ARoberts18

    I tried the above, and it doesn’t work. I’ve approached this from a different angle and I still can’t do it.

    Code:
    savedSearchId = “344”; //search all solutions owned by this person
    $request = new SearchRequest();
    $request->searchRecord = $search;
    $searchResponse = $service->search($request);

    if (!$searchResponse->searchResult->status->isSuccess) {
    echo “

    SEARCH ERROR,
    message: ” . $searchResponse->searchResult->status->statusDetail[0]->message . ‘
    Code: ‘ . $searchResponse->searchResult->status->statusDetail[0]->code . ‘

    ‘;
    } else {
    echo “

    SEARCH SUCCESS,
    records found: ” . $searchResponse->searchResult->totalRecords . “

    n”;
    $records = $searchResponse->searchResult->searchRowList->searchRow;

    if($searchResponse->searchResult->totalRecords > 0) {
    echo ‘

    ‘;
    echo ‘

    ‘;
    $iterator = 1;
    foreach ($records as $record) {
    $customFields = $record->basic->customFieldList->customField;

    //flush the data
    echo ‘

    ‘;
    echo ‘

    ‘;
    echo ‘

    ‘;
    }

    echo ‘

    Title Internal ID
    ‘ . $record->basic->name[0]->searchValue;
    echo ‘
    ‘ . $record->basic->customFieldList->customField->custrecord100[0]->searchValue . ‘

    ‘;
    } else {
    echo ‘

    Search returned 0 rows

    ‘;
    }

    }

    ?>
    Cannot get the custom field to show.

    Also, how do I apply filters to this kind’ve search?

  • #6604

    chanarbon

    HI ARoberts18,

    With the solution provided from the previous email, it is more related to the get operation. More or less, the custom fields are always returned on the customFieldList attribute of the object. Have you tried using var_dump to get the exact context of the object?

  • #6605

    ARoberts18

    Yeah I’ve used var_dump yes, and this is what I get from one of the records (it found 30 records).

    Code:
    object(CustomRecordSearchRow)#1003 (7) { [“basic”]=> object(CustomRecordSearchRowBasic)#1004 (14) { [“recType”]=> object(RecordRef)#1005 (4) { [“internalId”]=> string(3) “122” [“externalId”]=> NULL [“type”]=> NULL [“name”]=> NULL } [“altName”]=> NULL [“availableOffline”]=> NULL [“created”]=> array(1) { [0]=> object(SearchColumnDateField)#1006 (2) { [“searchValue”]=> string(29) “2016-09-27T07:00:00.000-07:00” [“customLabel”]=> NULL } } [“externalId”]=> NULL [“id”]=> NULL [“internalId”]=> NULL [“isInactive”]=> NULL [“lastModified”]=> NULL [“lastModifiedBy”]=> NULL [“name”]=> array(1) { [0]=> object(SearchColumnStringField)#1007 (2) { [“searchValue”]=> string(6) “GVSM62” [“customLabel”]=> NULL } } [“owner”]=> NULL [“parent”]=> NULL [“customFieldList”]=> object(SearchColumnCustomFieldList)#1008 (1) { [“customField”]=> array(3) { [0]=> object(SearchColumnSelectCustomField)#1009 (4) { [“searchValue”]=> object(ListOrRecordRef)#1010 (4) { [“name”]=> NULL [“internalId”]=> string(1) “1” [“externalId”]=> NULL [“typeId”]=> string(3) “123” } [“customLabel”]=> NULL [“internalId”]=> string(3) “669” [“scriptId”]=> string(12) “custrecord99” } [1]=> object(SearchColumnSelectCustomField)#1011 (4) { [“searchValue”]=> object(ListOrRecordRef)#1012 (4) { [“name”]=> NULL [“internalId”]=> string(5) “39145” [“externalId”]=> NULL [“typeId”]=> string(2) “-2” } [“customLabel”]=> NULL [“internalId”]=> string(3) “675” [“scriptId”]=> string(13) “custrecord105” } [2]=> object(SearchColumnStringCustomField)#1013 (4) { [“searchValue”]=> string(24) “jj_elliott@hotmail.co.uk” [“customLabel”]=> NULL [“internalId”]=> string(3) “670” [“scriptId”]=> string(13) “custrecord100” } } } } [“fileJoin”]=> NULL [“messagesJoin”]=> NULL [“ownerJoin”]=> NULL [“userJoin”]=> NULL [“userNotesJoin”]=> NULL [“customSearchJoin”]=> NULL }
    Quite a lot of nulls in there.

    I just want to get the value of the custom fields.

  • #6606

    chanarbon

    There should be an object called CustomRecordSearchBasic for you to try

  • #6607

    chanarbon

    Also, for each CustomRecordSearchRowBasic, it should contain the values of the custrecord100 field

You must be logged in to reply to this topic.