问题
I have downloaded 2012_2 PHP Toolkit for Netsuite. With less or no documentation it would be great if someone can give me headstart on how to connect to a Custom Record List Created in Netsuite
The list is labs under lists->support in netsuite.
Through PHP i want to enter data to that list I dont need the entire code, I just need a headstart on how to connect to that custom record I created in netsuite. I have the internal id of the custom record and the name of the custom record in netsuite.
回答1:
For others to refer later on this could be helpful
$service = new NetSuiteService();
// Create a object for lab name in netsuite
$labName = new SelectCustomFieldRef();
$labName->value = new ListOrRecordRef();
$labName->value->internalId = $lab_number; // your input
$labName->internalId = "xxxxxx"; // internal id of the input in Netsuite
$labCustomRecord = new CustomRecord();
$labCustomRecord->recType = new RecordRef();
$labCustomRecord->customForm = "xxxx"; // form id
$labCustomRecord->recType->internalId = "xx"; // internal id
$labCustomRecord->customFieldList = new CustomFieldList();
$labCustomRecord->customFieldList->customField = $labName
$addRequest = new AddRequest();
$addRequest->record = $labCustomRecord;
if(!$addResponse[$i]->writeResponse->status->isSuccess) {
echo "<pre>"; print_r("Error"); echo "</pre>"; exit();
} else {
echo "<pre>"; print_r("Success"); echo "</pre>"; exit();
}
回答2:
Below is a sample code on how to add new record for a custom record type using PHP Toolkit 2012.2
//create an instance of the fields of the custom record
$customFieldList = new StringCustomFieldRef();
$customFieldList->internalId = "custrecord_name";
$customFieldList->value = "Test from PHP toolkit";
$basicCustomRecord = new CustomRecord();
$basicCustomRecord->name = "PHP Toolkit 2012.2";
$basicCustomRecord->recType = new RecordRef();
$basicCustomRecord->recType->internalId = "14"; //Record Type's internal ID (Setup > Customization > Record Types > Basic Record Type (Internal ID=14)
$basicCustomRecord->customFieldList = new CustomFieldList();
$basicCustomRecord->customFieldList->customField = $customFieldList;
$addRequest = new AddRequest();
$addRequest->record = $basicCustomRecord;
$addResponse = $service->add($addRequest);
if (!$addResponse->writeResponse->status->isSuccess) { echo "ADD ERROR"; exit();}
else { echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;}
?>
this same code is available in SuiteAnswers. There are a number of other sample codes for PHP Toolkit 2012.2 in SuiteAnswers as well. If you have time, you can review those code for your future reference.
Regards!
来源:https://stackoverflow.com/questions/13204345/nesuite-php-custom-record