A sample code to update a Custom record type via Web Services using PHP.
Note: This article requires existing knowledge of Web Services and PHP.
Sample code snippet:
require_once("../PHPtoolkit.php");
require_once("login_info.php");
global $myNSclient;
//create an array for the custom record type which will set the custom record ID, etc.
$recordTypeRef = array(
"internalId" => "7" // Record type's internal ID
);
//create an array for the values for the fields of the custom record
$customFieldRef = array(
"internalId" => "custrecord_othername_name",
"value" => "Test from PHP toolkit"
);
// create a String Custom Field object
// other custom field objects: StringCustomFieldRef, BooleanCustomFieldRef, LongCustomFieldRef, DoubleCustomFieldRef, MultiSelectCustomFieldRef, SelectCustomFieldRef, DateCustomFieldRef
$customFieldRecord = new nsComplexObject("StringCustomFieldRef");
// set the array as values of the custom field object
$customFieldRecord -> setFields($customFieldRef);
// create an array for the values of the regular fields
$customRecordUpdateFields = array(
"internalId" => "1", // Internal ID - record to be updated
"recType" => $recordTypeRef, // set the array for the record type to recType
"customFieldList" => array("customField" => $customFieldRecord)
);
// create a new CustomRecord object
$mycustomRecord = new nsComplexObject("CustomRecord");
// set the array as values
$mycustomRecord -> setFields($customRecordUpdateFields);
// Update custom record
$updateResponse = $myNSclient->update($mycustomRecord);
if ($updateResponse->isSuccess) {
echo "<font color='green'><b>SUCCESSFULLY UPDATED Custom Record!</b></font>";
} else {
echo "<font color='red'><b>";
$updateResponse->statusDetail[0]->message;
echo "</b></font>";
}
The equivalent SOAP request:
<SOAP-ENV:Body>
<ns3:update>
<ns3:record xsitype="ns1:CustomRecord" internalId="1">
<ns1:recType internalId="7" />
<ns1:customFieldList>
<ns2:customField xsitype="ns2:StringCustomFieldRef" internalId="custrecord_othername_name">
<ns2:value>Test from PHP toolkit</ns2:value>
</ns2:customField>
</ns1:customFieldList>
</ns3:record>
</ns3:update>
</SOAP-ENV:Body>
***Note : This code works on PHP Toolkit Versions Older than 2012.2.
While not as pricey as some of the other coins, it holds a distinction over other coins in its beautiful and sought after layout and design. Expect to pay between $550-$1000 for this classic piece. buy runescape gold
ReplyDelete