You need to sign in to do that
Don't have an account?

Update a field with today's date based on a certain value being selected in another field
Hi, I have 2 fields in accounts - the first is "Lead Status" and the second is "Date Qualified". For tracking purposes. I would like today's date to be automatically populated in the "Date Qualified" field based on when "Qualified" is chosen in the "Lead Status" field.
I'd also like to make the "Date Qualified" field not able to be edited unless you are an admin.
Any help would be greatly appreciated.
Thank you.
No need for trigger here. Workflow is more easier to edit later if any changes occurred.
Create workflow from Your Name --> Setup --> create --> workflow & Approvals --> workflow rules.
1) Select Lead object
2) Give rule name your Evaluation criteria would be "created, and any time it’s edited to subsequently meet criteria" as per your requirement.
3) Rule Criteria Lead: Lead Status equals Qualified click save and next
4) Select workflow action new field update
5) Give name, Description select Date Qualified field to update.
6) Select "Use a formula to set the new value" and Put function Today() if your field type is Date or Now() if your field type is Date/Time.
7) Done
8) Active your workflow (Don't miss this step)
Thanks!
All Answers
John,
1.) for first part where you want to populate "Date Qualified" with today's date you can create an Apex Trigger(before insert,before update Trigger on Lead).Infact a workflow would also work.
2.) for the 2nd part,you can create a Validation rule where noone is able to edit the field except Admin.
Hi Vinit,
Any chance you could provide me with the actual code for this?
Hi John,
Try below code for the Trigger :-
Trigger updateDate on Lead(before insert,before update){
for(Lead le:Trigger.new){
if(le.status=='Qualified'){
le.Date_Qualified__c=system.today();
}
}
}
No need for trigger here. Workflow is more easier to edit later if any changes occurred.
Create workflow from Your Name --> Setup --> create --> workflow & Approvals --> workflow rules.
1) Select Lead object
2) Give rule name your Evaluation criteria would be "created, and any time it’s edited to subsequently meet criteria" as per your requirement.
3) Rule Criteria Lead: Lead Status equals Qualified click save and next
4) Select workflow action new field update
5) Give name, Description select Date Qualified field to update.
6) Select "Use a formula to set the new value" and Put function Today() if your field type is Date or Now() if your field type is Date/Time.
7) Done
8) Active your workflow (Don't miss this step)
Thanks!
Thanks Ketan. That worked exactly as I wanted it to. Now just need to make the field only editable by admins and I'm set but I think I know how to do that. Thanks.
For access control you can use
1) Validaton rule.
(OR)
2) Make it read only through page layout (very easy)
Thanks Ketan got it all set up.
And add Date to field ‘Date_to_Send_email__c’ i.e today's date.