Friday, April 26, 2019

Attach Contact to Customer using PHP Toolkit 2013.1

Attaching a Contact to a Customer requires:
1. internalId of Contact which will be attached
2. internalId of Customer to which the Contact will be attached

Note: Contact cannot be attached to a Customer which is of type Individual.
It is possible to attach Contact to multiple Customers. For that the "Attach" method needs to be run for every particular Customer

Code example:

//include the PHP toolkit libraryrequire_once 'PHP_Toolkit_2013_1/NetSuiteService.php'; //create NetSuite service object$Service = new NetSuiteService(); //reference of the contact which will be attached to customer$AttachContactReference = new AttachContactReference(); ////contact phase//contact object needs to be specified as reference to record$ContactReference = new RecordRef(); //ID of the contact$ContactReference->internalId = '2062'; //say which contact is to be attached$AttachContactReference->contact = $ContactReference; ////customer phase//customer object needs to be specified as reference to record$RecordRef = new RecordRef(); //type of record$RecordRef->type = 'customer'; //ID of the customer$RecordRef->internalId = '959'; //say to which customer this contact will be attached$AttachContactReference->attachTo = $RecordRef; ////attach phase//attach request object$AttachRequest = new AttachRequest(); //point on what needs to be attached to what$AttachRequest->attachReference = $AttachContactReference; //execute attach$SearchResponse = $Service->attach($AttachRequest); 
echo '<pre>'; 
var_dump($SearchResponse); 
echo '</pre>';

No comments:

Post a Comment