+ Start a Discussion
Behzad Bahadori 18Behzad Bahadori 18 

Auto populate current UserName after editing an opportunity Field

I have two custome fields in my opportunity. right now the fields are being field manually. one filed is a checkbox, and what I want is as soon as an that check mark is checked, the name of the person that has checked it to be in another field under it . So I have Check1__c being checked, 

and I have NameUpdate__c to be field up by my name since I am workign on this opportunity right now
Best Answer chosen by Behzad Bahadori 18
Ketankumar PatelKetankumar Patel
If  NameUpdate__c field is text field then you can also update this field using workflow.

1) Create Workflow on Opportunity Object
2) Workflow Evaluation Criteria should be created, and every time it’s edited
3) Workflow Rule Critieria should be Opportunity: Check1 equals True
4) Using field update select this Text field and select formula to set the new value. (Formula: $User.FirstName + '  ' +$User.LastName)

All Answers

Ketankumar PatelKetankumar Patel
If  NameUpdate__c field is text field then you can also update this field using workflow.

1) Create Workflow on Opportunity Object
2) Workflow Evaluation Criteria should be created, and every time it’s edited
3) Workflow Rule Critieria should be Opportunity: Check1 equals True
4) Using field update select this Text field and select formula to set the new value. (Formula: $User.FirstName + '  ' +$User.LastName)
This was selected as the best answer
Ketankumar PatelKetankumar Patel
You can also do this using trigger.
  • If NameUpdate__c is user field then
  • trigger updatefield on Opportunity (before update) {
      for (Opportunity record:trigger.new) {
        if(record.Check1 == True) {
          record.NameUpdate__c = userinfo.getUserId();
        }
      }
    }
  • If NameUpdate__c is Text field then
  • trigger updatefield on Opportunity (before update) {
      for (Opportunity record:trigger.new) {
        if(record.Check1 == True) {
          record.NameUpdate__c = userinfo.getName();
        }
      }
    }
Behzad Bahadori 18Behzad Bahadori 18
@Ketankumar Patel , Thank you so much for the respond, can you tell me what is the formula field for current Date, I have this DATEVALUE(Today()) and its keep showing 10/20/2015 it doesnt change it even when I just made new opportunity It didnt change it
Ankit Kalsara 14Ankit Kalsara 14
Hi Ketankumar,

I tried the same code as you provided but it is not working.

trigger populate_current_user on Applications_Time_Tracking__c (before update) {

    // populate the current user name on record creation 
   for (Applications_Time_Tracking__c record:trigger.new) {    
      record.User__c = userinfo.getUserId();    
   }
}