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
GRStevenBrookesGRStevenBrookes 

Help with 'Simple' Trigger

Hi All,

 

Think this is easily acheivable but getting stuck peicing it all together.

 

I have a custom object called CMC__c which has a field,  Assigned_To__c (User Lookup). What I would like is that when someone edits the record that the Assigned_To__c field is updateing to the user that made the edit.

 

Hope this makes sense.

 

Thanks in advance.

igoldsteinigoldstein

You should be able to achieve this with a workflow rule -- no Apex code necessary.

TejTej
    trigger myTrigger on CMC__c(after update) {

	if( trigger.isUpdate ){                                     
        		for( CMC__c c: trigger.new ){
            
           			 
              			  c.Assigned_To__c= userInfo.getUserId();

                		       
        		 }   
  	 }

}