Netsuite | Search PHP webservice – sample code
As per the Suite Talk Web Services Platform Guide; The search operation is used to execute a search on a specific record type based on a set of criteria. You can search by defining search filter fields on the record, joined fields on an associated record, search return columns, or joined search return columns from an associated record. The results of the search can be complete records, or a select set of fields specified through search return columns. This example will guide developer how to perform a search operation thru web service using PHPToolkit.
require_once 'PHPtoolkit.php';
require_once 'login_info.php';
global $myNSclient;
# SEARCH EMPLOYEE
# ===============
//create a search value
$strFirstname = "E";
$employeeSearch = new nsComplexObject("EmployeeSearchBasic");
$employeeSearch->setFields(array("firstName" => array(
"operator" => "startsWith",
"searchValue"=> $strFirstname,
"operatorSpecified" => true)));
$myNSclient->setSearchPreferences(false);
try
{
$searchResponse = $myNSclient->search($employeeSearch);
$totalRecords = $searchResponse->totalRecords;
if ($totalRecords > 0)
{
foreach ($searchResponse->recordList as $record)
{
$employee_internalId = $record->getField('internalId');
$employee_firstname = $record->getField('firstName');
$employee_lastname = $record->getField('lastName');
echo "Internal Id: ". $employee_internalId;
echo "First Name: " . $employee_firstname;
echo "Last Name: " . $employee_lastname;
}
}
else
{
echo "No result found.";
}
}
catch (Exception $e)
{
echo "Employee is not found. Please try again.";
exit();
}
Related posts:
Connect!
Enter your WordPress.com blog URL
http://.wordpress.com
Proceed