0

I have a PHP web application using the SForce Partner Client to connect with Salesforce. I am creating a new Record Type for a custom object.

How can I insert a record with that new Record Type in Salesforce using the Partner Client?

If this would be an existing Record Type I am assuming I could just use the RecordTypeId, but since it is a new one how can I ensure the value will be correct as it is deployed through different sandboxes?

0

In general, you'd call describeSObjects, which includes a response for the record types available and their ID values. From there, you can set the RecordTypeId as normal. You'd want to cache this describe information for each org so you don't need to call it repeatedly. It's also vaguely possible to use the record type Name, but only if it is unique in the org. My PHP is rusty, as I haven't used in probably a decade, but it would probably look something like:

$recordType = new SObject();
$recordType->fields = new array('Name'=>'MyRecordTypeName');
$record->fields->RecordType = $recordType;

However, this example is only loosely based on what I recall of the language, so you will need to do some research. You may find this documentation helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.