NetSuite Development Notes
Tuesday, June 25, 2019
Execute searchBasic for Purchase Orders that contains a specific Item via PHP Toolkit
Below is a sample code in PHP that searches for all Purchase Orders that contain a specific item.
require_once 'PHP_Toolkit_2012_2/NetSuiteService.php'; //include the PHP toolkit service library$service = new NetSuiteService(); //initialize the netsuite service - the main object$search = new TransactionSearchBasic(); //search for transaction in BASIC mode$RecordRefsIDs = Array('1551', '21687', '21696'); //IDs of transactions to search for$SearchMultiSelectField = new SearchMultiSelectField(); //set up multiselect field to which IDs will be put$RecordRefs = Array(); //array to hold IDs of transactions to search for//fill array of record references with RecordRef objectsfor($i = 0; $i < sizeof($RecordRefsIDs); $i++) { $RecordRef = new RecordRef(); //each ID needs to be presented as RecordRef $RecordRef->internalId = $RecordRefsIDs[$i]; //here the ID is put as RecordRef internal ID array_push($RecordRefs, $RecordRef); // add the ID, now as RecordRef to array of such objects so it can be used for searching}$SearchMultiSelectField->searchValue = $RecordRefs; //put IDs of transactions to search for as a search value$SearchMultiSelectField->operator = 'anyOf'; //set operator according to which search will be executed. Values are anyOf or noneOf$search->internalId = $SearchMultiSelectField; //IDs in form of multiselect field are assigned for search on search object$request = new SearchRequest(); //common search $request->searchRecord = $search; //specifying BASIC transaction search to common search$searchResponse = $service->search($request); //execute the search and gather responseecho "<pre>";var_dump($searchResponse); // dump the response on the screen so it is easy to search through the returned objectecho "</pre>";
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment