<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $search = new CustomRecordSearchAdvanced(); $search->savedSearchId = "63"; $request = new SearchRequest(); $request->searchRecord = $search; $searchResponse = $service->search($request); if (!$searchResponse->searchResult->status->isSuccess) { echo "SEARCH ERROR"; } else { echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords . "\n"; $records = $searchResponse->searchResult->searchRowList->searchRow; foreach ($records as $record) { echo "Name: " . $record->basic->name->searchValue . "\n"; } } ?>
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->useRequestLevelCredentials(false); $req = new LoginRequest(); $req->passport = $service->passport; $service->login($req); $po = new PurchaseOrder(); $po->entity = new RecordRef(); $po->entity->internalId = 1; $po->itemList = new PurchaseOrderItemList(); $poi = new PurchaseOrderItem(); $poi->item = new RecordRef(); $poi->item->internalId = 104; $poi->quantity = 3; $po->itemList->item = array($poi); $request = new AddRequest(); $request->record = $po; $addResponse = $service->add($request); if (!$addResponse->writeResponse->status->isSuccess) { echo "ADD ERROR"; exit; } else { echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; } echo "\n-----------------------\n"; $gr = new GetRequest(); $gr->baseRef = new RecordRef(); $gr->baseRef->internalId = $addResponse->writeResponse->baseRef->internalId; // code completion does not work here since baseRef is baseRef in the GetRequest def comment
<?php namespace NetSuite\WebServices; require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******'); $request = new GetRequest(); $request->baseRef = new RecordRef(); $request->baseRef->internalId = "883"; $request->baseRef->type = "customer"; $getResponse = $service->get($request); if (!$getResponse->readResponse->status->isSuccess) { echo "GET ERROR"; } else { $customer = $getResponse->readResponse->record; echo "GET SUCCESS, customer:"; echo "\nCompany name: " . $customer->companyName; echo "\nInternal Id: " . $customer->internalId; echo "\nEmail: " . $customer->email . "\n"; $addressBookListArray = $customer->addressbookList->addressbook; if (is_array($addressBookListArray)) { foreach ($addressBookListArray as $address) { echo "\nAddress:\n"; echo $address->label . "\n" . $address->attention . "\n" . $address->addressee . "\n" . $address->phone . "\n" . $address->city . "\n" . $address->state . "\n" . $address->zip . "\n" . $address->country . "\n\n"; } } else { $address = $addressBookListArray; echo "\nAddress:\n"; echo $address->label . "\n" . $address->attention . "\n" . $address->addressee . "\n" . $address->phone . "\n" . $address->city . "\n" . $address->state . "\n" . $address->zip . "\n" . $address->country . "\n\n"; }
<?php //without category and launchyear require 'PHPToolkit/NSconfig.php'; require 'PHPToolkit/NetSuiteService.php'; require_once 'PHPToolkit/NSPHPClient.php'; echo "Connecting to server ..........\n"; $savedsrchid = "1453"; //saved search id $ct = 0; $pageindex = 0; $service = new NetSuiteService(); $d = 0; $search = new TransactionSearchAdvanced(); $search->savedSearchId = $savedsrchid; //Saved Search internal ID, where the internal id's of all sales order records are saved $cnt = 0; $request = new SearchRequest(); $request->searchRecord = $search; $searchResponse = $service->search($request); //check if the records are present? if (!$searchResponse->searchResult->status->isSuccess) { echo "SEARCH ERROR"; } else { echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords . "\n"; $totalRecords = $searchResponse->searchResult->totalRecords; $noofpages = $searchResponse->searchResult->totalPages;
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $request = new GetRequest(); $request->baseRef = new RecordRef(); $request->baseRef->internalId = "21"; $request->baseRef->type = "customer"; $getResponse = $service->get($request); if (!$getResponse->readResponse->status->isSuccess) { echo "GET ERROR"; } else { $customer = $getResponse->readResponse->record; echo "GET SUCCESS, customer:"; echo "\nCompany name: " . $customer->companyName; echo "\nInternal Id: " . $customer->internalId; echo "\nEmail: " . $customer->email; } ?>
<?php namespace NetSuite\WebServices; require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******'); // create Customer record $customer1 = new Customer(); $name = 'customer_php_async_1'; $customerFields1 = array('entityId' => $name, 'companyName' => $name, 'externalId' => $name); setFields($customer1, $customerFields1); $customer2 = new Customer(); $name2 = 'customer_php_async_2'; $customerFields2 = array('entityId' => $name2, 'companyName' => $name2, 'externalId' => $name2); setFields($customer2, $customerFields2); // perform async add operation $asyncreq = new AsyncAddListRequest(); $asyncreq->record = array($customer1, $customer2); $checkAsync = $service->asyncAddList($asyncreq); // get job id $jobId = $checkAsync->asyncStatusResult->jobId; $checkasyncreq = new CheckAsyncStatusRequest(); $checkasyncreq->jobId = $jobId; while ($checkAsync->asyncStatusResult->status == 'pending' || $checkAsync->asyncStatusResult->status == 'processing') { sleep(10); $checkAsync = $service->checkAsyncStatus($checkasyncreq); } // once it is done processing, get the result $getasyncreq = new GetAsyncResultRequest(); $getasyncreq->jobId = $jobId;
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setSearchPreferences(false, 20); $emailSearchField = new SearchStringField(); $emailSearchField->operator = "startsWith"; $emailSearchField->searchValue = "j"; $search = new EmployeeSearchBasic(); $search->email = $emailSearchField; $request = new SearchRequest(); $request->searchRecord = $search; $searchResponse = $service->search($request); if (!$searchResponse->searchResult->status->isSuccess) { echo "SEARCH ERROR"; } else { echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords; } ?>
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $svr = new getSelectValueRequest(); $svr->fieldDescription = new GetSelectValueFieldDescription(); $svr->pageIndex = 1; /*$svr->fieldDescription->recordType = RecordType::salesOrder; $svr->fieldDescription->sublist = "itemList"; $svr->fieldDescription->field = "price"; $svr->fieldDescription-> */ $priceFields = array('recordType' => RecordType::salesOrder, 'sublist' => 'itemList', 'field' => 'price', 'filterByValueList' => array('filterBy' => array(array('field' => 'item', 'sublist' => 'itemList', 'internalId' => '458')))); setFields($svr->fieldDescription, $priceFields); $gsv = $service->getSelectValue($svr); $id = null; foreach ($gsv->getSelectValueResult->baseRefList->baseRef as $pricelevel) { if ($pricelevel->name == 'Custom') { $id = $pricelevel->internalId; break; } } if ($id != null) { echo "Custom price level id is " . $id . "\n"; } else { echo "Custom price level not found " . $id . "\n"; } $so = new SalesOrder(); $so->entity = new RecordRef(); $so->entity->internalId = 21; $so->itemList = new SalesOrderItemList();
<?php namespace NetSuite\WebServices; require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******'); $svr = new getSelectValueRequest(); $svr->fieldDescription = new GetSelectValueFieldDescription(); $svr->pageIndex = 1; /*$svr->fieldDescription->recordType = RecordType::salesOrder; $svr->fieldDescription->sublist = "itemList"; $svr->fieldDescription->field = "price"; $svr->fieldDescription-> */ $priceFields = array('recordType' => RecordType::salesOrder, 'sublist' => 'itemList', 'field' => 'price', 'filterByValueList' => array('filterBy' => array(array('field' => 'item', 'sublist' => 'itemList', 'internalId' => '45')))); setFields($svr->fieldDescription, $priceFields); $gsv = $service->getSelectValue($svr); $id = null; foreach ($gsv->getSelectValueResult->baseRefList->baseRef as $pricelevel) { if ($pricelevel->name == 'Custom') { $id = $pricelevel->internalId; break; } } if ($id != null) { echo "Custom price level id is " . $id . "\n"; } else { echo "Custom price level not found " . $id . "\n"; } $so = new SalesOrder();
<?php //including organisation type require 'PHPToolkit/NSconfig.php'; require 'PHPToolkit/NetSuiteService.php'; require_once 'PHPToolkit/NSPHPClient.php'; echo "Connecting to server ..........\n"; $ct = 0; $pageindex = 0; $service = new NetSuiteService(); $search = new TransactionSearchAdvanced(); $search->savedSearchId = "1414"; //Saved Search internal ID, where the internal id's of all sales order records are saved $cnt = 0; $request = new SearchRequest(); $request->searchRecord = $search; $searchResponse = $service->search($request); //check if the records are present? if (!$searchResponse->searchResult->status->isSuccess) { echo "SEARCH ERROR"; } else { echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords . "\n"; $totalRecords = $searchResponse->searchResult->totalRecords; $noofpages = $searchResponse->searchResult->totalPages; $noofpages = round($noofpages); for ($p = 0; $p < $noofpages; $p++) { if ($ct != 0) {
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $po = new PurchaseOrder(); $po->entity = new RecordRef(); $po->entity->internalId = 162; $po->itemList = new PurchaseOrderItemList(); $poi = new PurchaseOrderItem(); $poi->item = new RecordRef(); $poi->item->internalId = 104; $poi->quantity = 3; $po->itemList->item = array($poi); $request = new AddRequest(); $request->record = $po; $addResponse = $service->add($request); if (!$addResponse->writeResponse->status->isSuccess) { echo "ADD ERROR"; exit; } else { echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; } echo "\n-----------------------\n"; $gr = new GetRequest(); $gr->baseRef = new RecordRef(); $gr->baseRef->internalId = $addResponse->writeResponse->baseRef->internalId; $gr->baseRef->type = "purchaseOrder"; $getResponse = $service->get($gr); if (!$getResponse->readResponse->status->isSuccess) { echo "GET ERROR"; exit;
private function _isOrderInNetSuite($order_id, $ns_user = 1) { $service = new NetSuiteService(NULL, [], $ns_user); $request = new GetRequest(); $request->baseRef = new RecordRef(); $request->baseRef->externalId = $order_id . ".0"; $request->baseRef->type = "salesOrder"; $getResponse = $service->get($request); $code = $getResponse->readResponse->status->statusDetail[0]->code; $this->netsuite_order = $getResponse->readResponse->record; if ($code == "INVALID_KEY_OR_REF") { $this->netsuite_order->code = $code; } if (!$getResponse->readResponse->status->isSuccess) { return FALSE; } else { return TRUE; } }
<?php namespace NetSuite\WebServices; require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******'); $service->useRequestLevelCredentials(false); $req = new LoginRequest(); $req->passport = $service->passport; $service->login($req); $po = new PurchaseOrder(); $po->entity = new RecordRef(); $po->entity->internalId = 38; $po->itemList = new PurchaseOrderItemList(); $poi = new PurchaseOrderItem(); $poi->item = new RecordRef(); $poi->item->internalId = 15; $poi->quantity = 3; $po->itemList->item = array($poi); $request = new AddRequest(); $request->record = $po; $addResponse = $service->add($request); if (!$addResponse->writeResponse->status->isSuccess) { echo "ADD ERROR"; exit; } else { echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; } echo "\n-----------------------\n"; $gr = new GetRequest();
<?php namespace NetSuite\WebServices; require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******'); $service->setSearchPreferences(false, 20); $noteSearchAdvance = new NoteSearchAdvanced(); $noteSearch = new NoteSearch(); $customerSearchBasic = new CustomerSearchBasic(); $searchValue = new RecordRef(); $searchValue->type = 'customer'; $searchValue->internalId = 883; $searchMultiSelectField = new SearchMultiSelectField(); setFields($searchMultiSelectField, array('operator' => 'anyOf', 'searchValue' => $searchValue)); $customerSearchBasic->internalId = $searchMultiSelectField; $noteSearch->customerJoin = $customerSearchBasic; $noteSearchAdvance->criteria = $noteSearch; $request = new SearchRequest(); $request->searchRecord = $noteSearchAdvance; $searchResponse = $service->search($request); if (!$searchResponse->searchResult->status->isSuccess) { echo "SEARCH ERROR"; } else { echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords; } ?> <?php
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); // create Task record $task = new Task(); $task->title = "New Customer Follow-up"; $task->priority = TaskPriority::_high; $request = new AddRequest(); $request->record = $task; $addResponse = $service->add($request); if (!$addResponse->writeResponse->status->isSuccess) { echo "ADD ERROR"; } else { echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; } ?>
function getNetSuiteHosts($account_id) { $NetSuiteService = new NetSuiteService(); $NetSuiteService->setPassport($account_id, null, null, null); $dataCenterUrlsRequest = new GetDataCenterUrlsRequest(); $dataCenterUrlsRequest->account = $account_id; $dataCenterUrlsResponse = $NetSuiteService->getDataCenterUrls($dataCenterUrlsRequest); return $dataCenterUrlsResponse->getDataCenterUrlsResult->dataCenterUrls; }
public function initalizeDependencies() { require_once '../../PHPToolkit/NetSuiteService.php'; $this->service = NetSuiteService::fromConfig($this->config); }
<?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); // create Customer record $customer1 = new Customer(); $name = 'customer_php_async_1'; $customerFields1 = array('entityId' => $name, 'companyName' => $name, 'externalId' => $name); setFields($customer1, $customerFields1); $customer2 = new Customer(); $name2 = 'customer_php_async_2'; $customerFields2 = array('entityId' => $name2, 'companyName' => $name2, 'externalId' => $name2); setFields($customer2, $customerFields2); // perform async add operation $asyncreq = new AsyncAddListRequest(); $asyncreq->record = array($customer1, $customer2); $checkAsync = $service->asyncAddList($asyncreq); // get job id $jobId = $checkAsync->asyncStatusResult->jobId; $checkasyncreq = new CheckAsyncStatusRequest(); $checkasyncreq->jobId = $jobId; while ($checkAsync->asyncStatusResult->status == 'pending' || $checkAsync->asyncStatusResult->status == 'processing') { sleep(10); $checkAsync = $service->checkAsyncStatus($checkasyncreq); } // once it is done processing, get the result $getasyncreq = new GetAsyncResultRequest(); $getasyncreq->jobId = $jobId; $getasyncreq->pageIndex = "1"; $result = $service->getAsyncResult($getasyncreq); ?>