+ 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;