Skip to main content
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?
5 respostas
  1. 25 de nov. de 2019, 23:49
    Ok, checking the forums, the answers are mixed.

    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

     
0/9000