function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alkemacsalkemacs 

Update a lookup field with the Salesforce API using an external id

Hi ! 

I tried to create tasks with the REST API and update the "Name" field with a contact.

It worked well when I used "WhoId" : "00000WSSFSEFF",

but when I tried to use an external ID I got this error message : 

[{"message":"Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:7, column:21]","errorCode":"JSON_PARSER_ERROR"}]
 

URL : https://domain.my.salesforce.com/services/data/v20.0/sobjects/task

BODY :
{ "OwnerId": "0000XXX0000",
"Type": "Email",
"Subject": "Upsell",
"Status": "Not Started",
"Priority":"Normale",
"WhoId": { "ExternalId__c" : 4051 }
}

I also tried "Who": { "ExternalId__c" : 4051 }, and lots of other syntax but nothing worked.

Can you help me to solve this, please ? 

PawanKumarPawanKumar
Hi ,

can you please try below.

{ "OwnerId": "0000XXX0000",
"Type": "Email",
"Subject": "Upsell",
"Status": "Not Started",
"Priority":"Normale",
"Contact__r": { "ExternalId__c" : 4051 }
}

Regards,
Pawan Kumar
alkemacsalkemacs

Hi Pawan ! 

Thanks for your response.

I got this error message : [{"message":"No such column 'Contact__r' on sobject of type Task","errorCode":"INVALID_FIELD"}]

 

Khushboo wadhwa 20Khushboo wadhwa 20
Hi @alkemacs

I am getting the same error. Were you able to resolve this?
Ben FalterBen Falter
I'm also getting the same error. Does anybody have a solution here? 
Ben FalterBen Falter
Actually, just found this ideaexchange post. Looks like it's impossible to update for polymorphic fields: https://success.salesforce.com/ideaView?id=08730000000Br0QAAS