You need to sign in to do that
Don't have an account?
Steve Thurston 3
Set new Lead RecordTypeId from API
When creating a new Lead via an API call, I need to set the RecordType. To do that, it seems as if I need the RecordTypeId. But for testing, that ID is going to be different in Sandbox vs. Production. So I don't want to hardcode the RecordTypeId.
When creating a new Lead via API, is there a way to specify the Record Type using its name instead of its ID? Or at least have the API look up the RecordTypeId based on its name?
When creating a new Lead via API, is there a way to specify the Record Type using its name instead of its ID? Or at least have the API look up the RecordTypeId based on its name?
Found this one that seems to think setting a record type on create for a Lead is not possible.
https://developer.salesforce.com/forums/?id=9060G000000Bg34QAC
Or we have an example for Oppty using JSON which seems to use the Record Type name.
https://developer.salesforce.com/forums/?id=9060G000000BduFQAS
Other option, thinking outside the box, could you use that previous code in an before insert trigger and test the lead creation source as the API, or tag a check box/picklist in the lead saying "API created", and fire the trigger on the before insert and the checkbox/picklist?
Hope one of those ideas helps.
Regards
Andrew
All Answers
Something like:
where 'myRecordTypeName' is the name of your record type.
Note that we also need to state the Object for which we need the record type, in this instance - 'Lead'
HTH
Regards
Andrew
Found this one that seems to think setting a record type on create for a Lead is not possible.
https://developer.salesforce.com/forums/?id=9060G000000Bg34QAC
Or we have an example for Oppty using JSON which seems to use the Record Type name.
https://developer.salesforce.com/forums/?id=9060G000000BduFQAS
Other option, thinking outside the box, could you use that previous code in an before insert trigger and test the lead creation source as the API, or tag a check box/picklist in the lead saying "API created", and fire the trigger on the before insert and the checkbox/picklist?
Hope one of those ideas helps.
Regards
Andrew
This may be old, but for whoever looking, I was able to resolve this by setting the following header to not auto-assign the record which will set default record type and name.
Set the following header:
Sforce-Auto-Assign: False