Skip to main content
Sooriya Kan (achievers) が「#Apex」で質問
Hi . 

I need to update the owner field in a custom object  when a custom field(which has look up to user) changes . I need to check when inserting and updating if the field has value and it is changed , then i need to update owner filed with the value. 

Object : Registration 

custome field : Adviser - look up to user 

need to chnage the owner field in the Registration obj with adviser field.

1)Having a  problem if that before update or after update trigger. 

If  I write after update trigger . I am  wondering if the trigger will run again and again. It will be a recursion. Pls help on this 
1 件の回答
  1. 2018年3月23日 21:28
    You need to write the trigger on after update .. before the update will work for you 

     

    Trigger TriggerName on Registration__c(before insert, before update) {

    for(Registration reg : Trigger.New){

    reg.OwnerId = reg.Adviser __r.id ;

    }

    }

     
0/9000