0

Question

Is it possible to modify ContactId field on an Opportunity? I get a field security error, but I did not find an option to change the security level of the field.

Motivation

I have records with missing ContactId that I want to fill in.

Example Python Code

from simple_salesforce import SalesForce

sf = Salesforce(username=SALESFORCE_EMAIL, password=SALESFORCE_PASSWORD, security_token=SALESFORCE_TOKEN)

opportunity_id = '0067Q00000Bw2rgQAB'
new_contact_id = '0037Q00000LOEvxQAH'
sf.Opportunity.update(opportunity_id, data={'ContactId': new_contact_id})

Error

'Unable to create/update fields: ContactId. Please check the security settings of this field and verify that it is read/write for your profile or permission set.'

0

1 Answer 1

3

Per the documentation, the ContactId field is read-only.

Read-only field that is derived from the opportunity contact role, which is created at the same time the opportunity is created. This field can only be populated when it’s created, and can’t be updated. To update the value in this field, change the IsPrimary flag on the OpportunityContactRole associated with this opportunity. Available in API version 46.0 and later.

1
  • "change the IsPrimary flag on the OpportunityContactRole associated" I think that solves that. Thank you!
    – icemtel
    Commented Dec 8, 2022 at 9:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .