+ Start a Discussion

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 ;