You need to sign in to do that
Don't have an account?
Ankit Kalsara 14
Auto Populate a Customer Lookup field with the Current User
Hi all,
I need to populate current user info when I create a new record. Username should apper before saving the record.
I wrote the trigger but it populates the current user info after I save the record.
I need to pre-populate the current user info when I create the new record.
Below is my trigger code.
trigger populate_current_user on Applications_Time_Tracking__c (before insert) {
// populate the current user name on record creation
for(Applications_Time_Tracking__c tt : Trigger.new){
if(tt.User__c == null){
tt.User__c = UserInfo.getUserId();
}
}
Can you please help.
I need to populate current user info when I create a new record. Username should apper before saving the record.
I wrote the trigger but it populates the current user info after I save the record.
I need to pre-populate the current user info when I create the new record.
Below is my trigger code.
trigger populate_current_user on Applications_Time_Tracking__c (before insert) {
// populate the current user name on record creation
for(Applications_Time_Tracking__c tt : Trigger.new){
if(tt.User__c == null){
tt.User__c = UserInfo.getUserId();
}
}
Can you please help.