Below is the sample code on how to include custom fields on the search column using advanced search
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$service->setSearchPreferences(true, 20);
// Search criteria of string
$SearchStringField = new SearchStringField();
$SearchStringField->operator = "is";
$SearchStringField->searchValue ="Test Item";
//call item search basic
$ItemSearchBasic = new ItemSearchBasic();
$ItemSearchBasic->itemId = $SearchStringField;
$ItemSearch = new ItemSearch();
$ItemSearch->basic = $ItemSearchBasic;
//Get Custom Column Date Field
$SearchColumnDateCustomField = new SearchColumnDateCustomField();
$SearchColumnDateCustomField->internalId = 'custitem_date';
//Get Custom Boolean Field
$SearchColumnBooleanCustomField = new SearchColumnBooleanCustomField();
$SearchColumnBooleanCustomField->internalId = 'custitem_checkbox';
//Get Custom String Field
$SearchColumnStringCustomField = new SearchColumnStringCustomField();
$SearchColumnStringCustomField->internalId = 'custitem_freeform';
//Get Custom Long Field
$SearchColumnLongCustomField = new SearchColumnLongCustomField();
$SearchColumnLongCustomField->internalId = 'custitem_integer_number';
//Get Custom Double Field
$SearchColumnDoubleCustomField = new SearchColumnDoubleCustomField();
$SearchColumnDoubleCustomField->internalId = 'custitem_dec_number';
//Get Select Custom Field
$SearchColumnSelectCustomField = new SearchColumnSelectCustomField();
$SearchColumnSelectCustomField->internalId = 'custitem_list_field';
//Get Multi Select Custom Field
$SearchColumnMultiSelectCustomField = new SearchColumnMultiSelectCustomField();
$SearchColumnMultiSelectCustomField->internalId = 'custitem_multi_select';
//custom field list
$SearchColumnCustomFieldList = new SearchColumnCustomFieldList();
$SearchColumnCustomFieldList->customField = array($SearchColumnDateCustomField,
$SearchColumnBooleanCustomField,
$SearchColumnStringCustomField,
$SearchColumnLongCustomField,
$SearchColumnDoubleCustomField,
$SearchColumnSelectCustomField,
$SearchColumnMultiSelectCustomField);
$ItemSearchRowBasic = new ItemSearchRowBasic();
$ItemSearchRowBasic->internalId = new SearchColumnSelectField();
$ItemSearchRowBasic->customFieldList = $SearchColumnCustomFieldList;
//Item Search Row
$ItemSearchRow = new ItemSearchRow();
$ItemSearchRow->basic = $ItemSearchRowBasic;
$search = new ItemSearchAdvanced();
$search->criteria = $ItemSearch;
$search->columns = $ItemSearchRow;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
var_dump($searchResponse);
}
?>
Thank you for the example.
ReplyDeleteDo you have any example for Time Entry? TimeEntrySearchAdvanced();