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
annoyingmouseannoyingmouse 

CreatedById.Name...?

HI there,

 

I've a custom object with a number of custom fields and a requirement to make one of those fields a read only field that equals the name of the user who created the record.

 

I first tried a Formula with CreatedById.Name but that's not accepted.

 

I've also tried to create a trigger on a text field but that caused all sorts of errors and exceptions:

 

trigger updateOfficer on Application__c (before insert) {

  for(Application__c a: Trigger.new){

    a.Officer__c = a.CreatedBy.Name;

  }

}

 

I'm hoping it's possible to use a Formula but if that's not going to work then I'll happily use a trigger but might need to some pointers... ;-)

 

Cheers,

 

Dom

Best Answer chosen by Admin (Salesforce Developers) 
annoyingmouseannoyingmouse

Solved it!

 

Text Formula field with:

 

CreatedBy.FirstName & " " &  CreatedBy.LastName

 

Thanks for your time,

 

Dom

All Answers

annoyingmouseannoyingmouse

Solved it!

 

Text Formula field with:

 

CreatedBy.FirstName & " " &  CreatedBy.LastName

 

Thanks for your time,

 

Dom

This was selected as the best answer
タン ビン チャンタン ビン チャン
Same issue. Many thanks
https://simnetkun.com