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
VSUVSU 

Need help in creating a trigger

Hi All,

I am new to creating triggers and so would appreciate any advise on how to create. I need the date field on the contact object to automatically populate when the date field is entered on the user object. I tried via process builder, but that didn't workas I had to disable it every time I needed to deactivate a user.
Raj VakatiRaj Vakati
trigger ContactTrigger on Contact (before insert) {
    User u = [Select Id  , CreatedDate from User where Id =:UserInfo.getUserId()] ;
    for(Contact c: Trigger.new){
        c.pi__conversion_date__c = u.CreatedDate ;
    }

}