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
AnushaAnusha 

Re : sObject assignment

Hi Guys...!

Hpoe all are doing well...

 

I have small Problem, 

I'm updateing the Object record in Class.

like below, I'm using sObject Instance to Update the record.

I'm assigning like below but Error was throwing.

sObj.Phone_No__c = '9999999999'; 

so i used like this, but same result.......... Error

sObj.get('Phone_No__c') = '9999999999';

update sObj;

 

And I'm getting Error like

" Field expression not allowed for generic SObject ".

 

 

 

 Now How can i update that perticular Record Phone No using sObject instance. 

 

and when I'm using Id then  no Error was throwing,

sObj.Id 



then No error

Best Answer chosen by Admin (Salesforce Developers) 
David81David81

I believe what you want, assuming you already have the existing sObject to work with is:

 

sObj.put('Phone_No__c','9999999999');

update sObj;

 

All Answers

David81David81

I believe what you want, assuming you already have the existing sObject to work with is:

 

sObj.put('Phone_No__c','9999999999');

update sObj;

 

This was selected as the best answer
AnushaAnusha

Thank You so much............!:smileyhappy:

Sooooo Sweet of You...........!