+ Start a Discussion

Value trying to update via before update not working

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 Sandrine
PriyaPriya (Salesforce Developers) 
Hey Sandrine,

Is this a psuedo code?

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