Thursday, 9 October 2014

Updating records with adding the user name


when ever user update the record that user name assign to the sales rep field.


Tigger updatesalesrep on account(before insert, before update){
   for(Account all : trigger.new){
     acc.ownerid = userinfo.getuserid();
     user user=[select name from user where id:= acc.ownerid ];
     acc.sales_rep__c = user.name;
  }
}

No comments:

Post a Comment