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
ndrannapareddyndrannapareddy 

ExternalId

Hi , 
How can i Update a record from Apex using External Id . 
Ex :
Account Object 

Fields 
ExternalId__c =123;//unique
name ='AccountName';

Not able to use Update 

Account a = new Account ();
a.ExternalId =123;
a.name = 'EditedName';

Update a;

when  i use this i am getting an Error saying to update Id field is required. 

Any help will be appriciated .




Satish_SFDCSatish_SFDC
Instead of the Update dml statement, you can use Upsert .

Regards,
Satish Kumar
ndrannapareddyndrannapareddy
I Dont want to Create a new Record . I only want to Update my Existing Accout without using AccountId . Just wanted to use ExternalId.
My ExternalId Field is Unique. 
I Already have that Record with ExternalId =123;