Sunday, March 10, 2019

PHP Toolkit 2012.2 > ItemSearchAdvanced Sample Code

This provides a sample code to make an ItemSearchAdvanced request using PHPToolkit 2012.2.  The article requires a basic understanding of PHP and Web Services to get this working.

The following example searches for an Item record, using internalIdNumber as filter.


     require_once './PHPToolkit/NetSuiteService.php';


     $service = new NetSuiteService();
     $service->setPreferences(false, false, false, true);

     // internalIdNumber Criteria
     $intIdNumCriteria = new SearchLongField();
     $intIdNumCriteria->operator = SearchLongFieldOperator::equalTo;
     $intIdNumCriteria->searchValue = '777';

     $itemSearchBasic = new ItemSearchBasic();
     $itemSearchBasic->internalIdNumber = $intIdNumCriteria;

     $itemSearch = new ItemSearch();
     $itemSearch->basic = $itemSearchBasic;

     $itemRowBasic = new ItemSearchRowBasic();
     $itemRowBasic->itemId = new SearchColumnStringField();
     $itemRowBasic->internalId = new SearchColumnSelectField();

     $itemSearchRow = new ItemSearchRow();
     $itemSearchRow->basic = $itemRowBasic;

     $itemSearchAdvanced = new ItemSearchAdvanced();
     $itemSearchAdvanced->criteria = $itemSearch;
     $itemSearchAdvanced->columns = $itemSearchRow;

     $request = new SearchRequest();
     $request->searchRecord = $itemSearchAdvanced;

     $searchResponse = $service->search($request);

The above codes produce a search SOAP request like the one below

               <ns4:searchRecord xsi:type="ns3:ItemSearchAdvanced">
                              <ns2:internalIdNumber operator="equalTo">
                              <ns2:internalId /> 
                              <ns2:itemId /> 

No comments:

Post a Comment