Sunday, May 19, 2019

PHP Toolkit 2011 > WS > Syntax to specify multiple id's when using the "any" of operator for search

When performing search via PHP 2011 toolkit in order to look through multiple records please refer to the sample below :

$RecordRefsIDs = Array('34778', '34782', '34781'); //IDs of transactions to search for
$RecordRefs = Array(); //array to hold IDs of transactions to search for

//fill array of record references with RecordRef objects
for($i = 0; $i < sizeof($RecordRefsIDs); $i++) {
$myResponderRefRecord = new nsRecordRef(array('internalId' => $RecordRefsIDs[$i]));//each ID needs to be presented as RecordRef

// SearchMultiSelectCustomField
$aSearchSelectCustomField = new nsComplexObject('SearchMultiSelectField');
$aSearchSelectCustomField->setFields(array( 'searchValue' => $myResponderRefRecord,
                                           'operator' => 'anyOf'));

$transactionsearch = new nsComplexObject('TransactionSearchBasic');
$transactionsearch->setFields( array( 'internalId' => $aSearchSelectCustomField));

$searchResponse  = $myNSclient->Search($transactionsearch);
$totalRecords = $searchResponse->totalRecords;


No comments:

Post a Comment