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
AbAb 

Value trying to update via before update not working

Hello,
I am trying to update a field in before udpate, but the updated value is not taken in to account, even in after update.
Any reason, i am doing wrong. 
Trigger (){

BeforeUpdate(List<Accounts> listOfAccounts){

  TempLoop= SOQL to get listOfAccounts.XYZ__r.Field__c
  for(Account acc : listOfAccounts){
       acc.FieldtoUpdate__c = TempLoop.XYZ__r.Field__c //It dont works 

   }
}

AfterUpdate(List<Accounts> listOfAccounts){
Print listOfAccounts[0].acc.FieldtoUpdate__c 
Result: it dont take in to account the updated field value

}

}

 
Best Answer chosen by Ab
PriyaPriya (Salesforce Developers) 
Hey Sandrine,

Is this a psuedo code?

Can you please provide the exact code and will check what is the issue.

Thanks!