This is a discussion on Setting a lookup field using an External ID in UPSERT within the Salesforce Coding Discussions forums, part of the Salesforce category; For the life of me, I am unable to perform an upsert
-
Setting a lookup field using an External ID in UPSERT
For the life of me, I am unable to perform an upsert and get a lookup field to get populated. I am getting the error "id value of incorrect type: 3". Here's how I have things configured.
Custom object 1
External_Id__c - this is a number field and has the attributes External ID and Unique checked to true. (example value is 3)
Custom object 2
Has a lookup field to Custom Object 1. When upserting, my PHP array sets this values to a value that exists in CustomObject1.External_Id__c (example value is 3)
Upserting a record here gets the error "id value of incorrect type: 3"
If I comment out the lookup field when upserting to Custom Object 2, a record is upserted with no errors.
Any ideas? Do I have to do anything special in the PHP code to get this foreign key relationship to work?
(also posted at Community - Setting a lookup field using an External ID in UPSERT - Perl, PHP, Python & Ruby Development - Salesforce.com Community)
-
If I am not mistaken, you are getting that error because a lookup can only be done on a Id field type (the join).
If you wanted to associate custom object 3 with custom object 1, you would need to put the Id of custom object 1 on 3.
let me know if that makes sense
-
I was under the impression that there were two ways to populate a lookup field on an object. The common way is to populate it with the ID of the record being looked up. Another way (I think) is top populate the field with the value of the External ID from the record being looked up and Salesforce will automatically resolve that to the correct record.
Reading the section "upsert() and Foreign Keys" in the API guide leads me to think this. What I don't know is how to apply this in the PHP toolkit. I was hoping I could just set the field value, but maybe it's not that easy.
Ideas?
-
I will look at it and see if that is the case and get back to you as soon as I can Scott
-
Scott were you able to get this fixed by the example that Simon posted in the Salesforce forums?
If you did, would you please share an example with us here? I would really appreciate it
~Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks