go-sfdc
go-sfdc copied to clipboard
Upsert External ID Issue dml
I'm getting the issue below with upserting a External ID. Thoughts Thanks!
This NOT_FOUND: Provided external ID field does not exist or is not accessible:
Code below
dml := &dml{ sobject: "Facebook_7FF__c", fields: map[string]interface{}{ "Ad_Spent_Cents__c": "$10000", "Clicks__c": "200", "Entered_Date_Time__c": "12/4/2019, 5:10:20 PM", "LMS_ID__c": "2324", "LMS_Record_ID__c": "e4f5591f-ca42-4eb5-bd4b-3d6a1d1b2602", "Leads__c": "5", "Period_End_Date__c": "11/27/2019", "Period_Start_Date__c": "11/27/2019", "Sales_Cents__c": "$2000", "Scheduled_ss__c": "2", "Person_Account__c": "a293i0000009ErBAAU", "clients__c": "1", "ss__c": "1", }, } dml.id = "a293i0000009ErBAAU" dml.externalField = "75bc21b7-201c-4a90-b716-506785a0c2a0"
Field is setup as Unique and External
So for the upsert to work with an external field, you need to provide the external field name and the value Here is the example from the documentation
type dml struct { sobject string fields map[string]interface{} id string externalField string }
func (d *dml) SObject() string { return d.sobject } func (d *dml) Fields() map[string]interface{} { return d.fields } func (d *dml) ID() string { return d.id } func (d *dml) ExternalField() string { return d.externalField }
sobjResources := sobject.NewResources(session)
dml := &dml{ sobject: "Account", } dml.id = "AccExID345" dml.externalField = "MyUID__c" dml.fields["Name"] = "Upsert Update"
upsertValue, err := sobjResources.Upsert(dml)
if err != nil { fmt.Printf("Upsert Error %s\n", err.Error()) return }
fmt.Println("Account Upsert") fmt.Println("-------------------") fmt.Printf("%+v\n", upsertValue)
so from your example, the external field is the field name and the id would be the 75...2a0