1

I searched through the documentation and it seems Lead creation is done by sending a hash of attributes. How do you specify the Lead owner? By email? User ID? Is there any documentation?

  • OwnerId field in lead is not a hash field on lead, but an 18 digit User ID. WHich is the primary key in user table. – Pranay Jaiswal Dec 10 '18 at 22:31
3

You can specify by username, email, Id, and for queues, Id and Name.


{ 
  "LastName": "Demo", 
  "Company": "Demo", 
  "Owner": {
    "attributes": { "type": "User" },
    "Username": "login@domain.com" 
  }
}

{ 
  "LastName": "Demo", 
  "Company": "Demo", 
  "Owner": {
    "attributes": { "type": "User" },
    "Email": "login@domain.com" 
  }
}

{ 
  "LastName": "Demo", 
  "Company": "Demo", 
  "OwnerId": "005.."
}

{ 
  "LastName": "Demo", 
  "Company": "Demo", 
  "OwnerId": "00G.."
}

{ 
  "LastName": "Demo", 
  "Company": "Demo", 
  "Owner": {
    "attributes": { "type": "Group" },
    "Name": "Queue Name" 
  }
}

You can get the User ID (005...) or Queue ID (00G...) from the User or Group tables, respectively.

  • Awesome. Thank you. I looked through the REST API doc (resources.docs.salesforce.com/216/latest/en-us/sfdc/pdf/…), but did not see this info. Is it documented somewhere? – B Seven Dec 10 '18 at 22:52
  • 1
    @BSeven I would have been willing to bet this is in the docs somewhere, but I can't seem to find it now. The closest I've gotten is this doc, but I'm not sure it explains things in detail enough (I don't think it does). At any rate, I hope you find this information useful. – sfdcfox Dec 10 '18 at 23:08
  • I get ERROR: JSON_PARSER_ERROR: Cannot deserialize instance of <unknown> from null value null or request may be missing a required field when using Email or Username. Are you sure it works? – B Seven Dec 11 '18 at 1:30
  • 1
    @BSeven Yes, all of the above forms work, as I actually tested a number of combinations and posted those that worked here (with redacted information, of course). The JSON has to be perfect, though, or you can easily get that error message. – sfdcfox Dec 11 '18 at 2:00
  • 1
    @BSeven The documentation always shows them written as such, so that's how I've always used them. I just tested this, though, and found that attributes is apparently case-insensitive, but type is case-sensitive. To be safe, consider always using lowercase for these two attributes. Deviating from the documentation is not advised. – sfdcfox Dec 14 '18 at 22:33

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.