I am trying to search for a customer by email. The Netsuite api documentation does not help much. Appreciate any help i can get. Thank You.
global $myNSclient;
$email = "myemail";
$item = new nsComplexObject('SearchStringField');
$item->setFields(array( 'searchValue' => $email, 'operator' => 'is'));
$search = new nsComplexObject('ContactSearchBasic');
$search->setFields($item);
$myNSclient->setSearchPreferences(false, 10);
$searchResponse = $myNSclient->search($search);
I got quite a few gray hairs trying to figure this out myself.
Below is the code to get a contact (different than a customer in Netsuite, both are native data types though) from their email. It will be very similar for a Customer.
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$recordRef = new RecordRef();
$recordRef->internalId = '-6'; //Internal ID for a customer is -2, contact is -6
$contactSearch = new ContactSearch(); //use CustomerSearch() for a customer
$contactSearchBasic = new ContactSearchBasic();//SearchRecordBasic
$contactSearchBasic->email = new SearchStringField();
$contactSearchBasic->email->searchValue = 'someone#somewhere.com';
$contactSearchBasic->email->operator = SearchStringFieldOperator::is;
$contactSearch->basic = $contactSearchBasic;
$searchRequest = new searchRequest(); //% contains a searchRecord
$searchRequest->searchRecord = $contactSearch;
$searchResponse = $service->search($searchRequest);
Related
Here is the situation.
I'm trying to get the proper class name of the serialized inventory item, however, when I'm doing a search (see the code below):
$type = new SearchEnumMultiSelectField();
$type->operator = 'anyOf';
$type->searchValue = array('serializedInventoryItem');
$search->type = $type;
$invetoryRef = new RecordRef();
$invetoryRef->internalId = '522216';
$params = new SearchMultiSelectField();
$params->operator = 'anyOf';
$params->searchValue = array($invetoryRef);
$search->serializedInventoryItem = $params;
However, when I do a search, I'm getting the following message: The field type's enum value is invalid for this search.
Why would I be getting the following error message?
Thanks!
Kevin
Found a solution, instead of using the code above, I used the following code:
$service = new NetSuiteService();
$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = 522216;
$request->baseRef->type = 'serializedInventoryItem';
$getResponse = $service->get($request);
That resolved the issue.
I'm attempting to plug a php based calendar management system into exchange 2007 calendars.
I have the below code setup at present.
$subject = 'Appointment with ..';
$request = new EWSType_CreateItemType();
$request->Items = new EWSType_NonEmptyArrayOfAllItemsType();
$request->Items->CalendarItem = new EWSType_CalendarItemType();
$request->Items->CalendarItem->Subject = $subject;
$date1 = new DateTime('2015-05-10T15:00:00+03:00');
$DateStart = $date1->format('Y-m-d H:i:00');
$date = new DateTime($DateStart);
$request->Items->CalendarItem->Start = $date->format('c');
$date1 = new DateTime('2015-05-10T17:00:00+03:00');
$DateEnd = $date1->format('Y-m-d H:i:00');
$date = new DateTime($DateEnd);
$request->Items->CalendarItem->End = $date->format('c');
$request->Items->CalendarItem->ReminderIsSet = false;
$request->Items->CalendarItem->ReminderMinutesBeforeStart = 15;
$request->Items->CalendarItem->Body = new EWSType_BodyType();
$request->Items->CalendarItem->Body->BodyType = EWSType_BodyTypeType::HTML;
$request->Items->CalendarItem->Body->_ = <<<EOD
<p><strong>Staff Attending</strong>:bob</p>
EOD;
$request->Items->CalendarItem->ItemClass = new EWSType_ItemClassType();
$request->Items->CalendarItem->ItemClass->_ = EWSType_ItemClassType::APPOINTMENT;
$request->Items->CalendarItem->Sensitivity = new EWSType_SensitivityChoicesType();
$request->Items->CalendarItem->Sensitivity->_ = EWSType_SensitivityChoicesType::NORMAL;
$request->Items->CalendarItem->Categories = new EWSType_ArrayOfStringsType();
$request->Items->CalendarItem->Categories->String = array(
'Client Meeting (Scheduled)'
);
$request->Items->CalendarItem->Location = "Showroom";
$request->SendMeetingInvitations = EWSType_CalendarItemCreateOrDeleteOperationType::SEND_ONLY_TO_ALL;
$request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->EmailAddress = "user#domain.com";
$request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->RoutingType = 'SMTP';
$n = 1;
$response = $ews->CreateItem($request);
This will setup an event in the users personal calendar just fine, but what I need to do is to get it to post to a public folder calendar which I have the folderID for.
If anyone could assist it would be greatly appreciated!
Try adding the line:
$request->SavedItemFolderId->FolderId->Id=$folder_id;
after the
$request = new EWSType_CreateItemType();
where $folder_id is your stupidly long microsoft folder id!!!!
I'm doing the same right now.
You have to replace the SEND_ONLY_TO_ALL with SEND_TO_NONE.
This means that we cannot send meeting invitations for appointments stored in a public folder (I've been trying to find a workaround for this problem for a couple weeks now).
I'm not sure if there are other problems in your request but this is surely an issue.
I have looked at some answers on here and tried putting them into action in my script; but it's not working, and I'm not sure why.
I am trying to update a custom field on an already-existing inventory item. Here is what I have so far
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$item = new InventoryItem();
$item->internalId = 72309;
$customFieldList = new CustomFieldList();
$customField = new StringCustomFieldRef();
$customField->value = utf8_encode("12345");
$customField->internalId = 'custitem_testinput';
$customFieldList->customField[] = $customField;
$item->customFieldList = $customFieldList;
$request = new UpdateRequest();
$request->record = $item;
$response = $service->update($request);
?>
I'm trying to pull the item record up by its internalID, and then update just 1 of its many custom fields.
This code doesn't error out, but it doesn't seem to do anything either. Looking at the var_dump of the objects, I can see an item object with just the parameters I've set populated, and everything else null.
What am I doing wrong?
This is a basic example showing how to update custom field in an existing record using PHP toolkit.
<?php
require_once 'PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$ItemId = '72309';
$ItemRecord= new InventoryItem();
//StringCustomFieldRef
$itemField= new StringCustomFieldRef();
$itemField->scriptId = 'custitem_part_lookup';
$itemField->value = 'test';
$customFieldList = new customFieldList();
$customFieldList->customField = array($itemField);
$ItemRecord->internalId = $ItemId ;
$ItemRecord->customFieldList = $customFieldList;
$updateRequest = new UpdateRequest();
$updateRequest->record = $ItemRecord;
$updateResponse = $service->update($updateRequest);
?>
For additional information you can visit Net Suite User Group
I'm trying to make a simple search with Netsuite Suitetalk API and the latest PHP Toolkit version.
Here is my code:
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$typeSearchField = new SearchStringField();
$typeSearchField->operator = SearchStringFieldOperator::is;
$typeSearchField->searchValue = "SalesOrder";
$search = new TransactionSearchBasic();
$search->recordType = $typeSearchField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
However, this request returns all records from Netsuite, not just the SalesOrders. Any idea what I'm doing wrong?
Update:
here is the working version, with the help of eliseobeltran. I had to change also $search->recordType with $search->type
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$SearchEnumMultiSelectField = new SearchEnumMultiSelectField(); //set up multiselect field to which IDs will be put
$SearchEnumMultiSelectField->searchValue = Array('_salesOrder'); //put IDs of transactions to search for as a search value
$SearchEnumMultiSelectField->operator = 'anyOf'; //set operator according to which search will be executed. Values are anyOf/noneOf
$search = new TransactionSearchBasic();
$search->type = $SearchEnumMultiSelectField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
Use "_salesOrder".
$SearchEnumMultiSelectField = new SearchEnumMultiSelectField(); //set up multiselect field to which IDs will be put
$SearchEnumMultiSelectField->searchValue = Array('_salesOrder'); //put IDs of transactions to search for as a search value
$SearchEnumMultiSelectField->operator = 'anyOf'; //set operator according to which search will be executed. Values are anyOf/noneOf
I'm currently trying to get a list of all Clarizen active projects so that I can modify some properties of its tasks. I've read the Clarizen API but it doesn't have many informations on PHP queries. What I managed to do so far is to query all the projects and then test their status one by one. In practice this is not a good approach since I have thousands of projects and not all of them are listed at once. Here's the code:
//LOGIN PROCCESS
$soapUrl = 'https://api.clarizen.com/v1.0/Clarizen.svc?WSDL';
$soapApiUrl = 'http://clarizen.com/api';
$soapConfig = array('exceptions' => 1);
$request = array();
$params = array(
'userName' => $username,
'password' => $password
);
$client = new SoapClient($soapUrl, $soapConfig);
$response = $client->Login($params);
$sessionId = $response->LoginResult->SessionId;
$userId = $response->LoginResult->UserId;
//Create a SOAP header containing the session ID for future requests
$header = new SoapHeader($soapApiUrl, 'Session', array("ID"=>$sessionId));
$client->__setSoapHeaders($header);
//Create a Query object
$userQuery = new stdClass();
//Set the name of the entity type you are querying
$userQuery->TypeName = 'Project';
//Select the fields you want retrieved from that entity
$userQuery->Fields = array('Name', 'State');
/* Doesnt work...*/
/*
$userQuery->Where = new stdClass();
$userQuery->Where->LeftExpression = new stdClass();
$userQuery->Where->LeftExpression->FieldName = 'State';
$userQuery->Where->Operator = 'Equal';
$userQuery->Where->RightExpression = new stdClass();
$userQuery->Where->RightExpression->Value = new stdClass();
$userQuery->Where->RightExpression->Value->TypeName = 'State';
$userQuery->Where->RightExpression->Value->Value = 'Active';
*/
$request[] = new SoapVar($userQuery, SOAP_ENC_OBJECT, 'EntityQuery', 'http://clarizen.com/api/queries');
//Execute the request
$result = $client->Execute(array("request"=>$request));
3 questions follow:
What is the right way to query in PHP with the "WHERE" clause
How to fetch the tasks of this project and then, for example create a Stopwatch for it.
How to continue the query until the hasMore flag is 0, or is there a way to fetch the entire thing all at once?
Thanks in advance.