Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upsert External ID Issue dml #50

Open
DanielAD84 opened this issue Apr 29, 2020 · 2 comments
Open

Upsert External ID Issue dml #50

DanielAD84 opened this issue Apr 29, 2020 · 2 comments

Comments

@DanielAD84
Copy link

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"

@DanielAD84
Copy link
Author

Field is setup as Unique and External

@g8rswimmer
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants