You need to sign in to do that
Don't have an account?
Trigger to update field when date field = today()
Hello everyone,
I tried creating workflow rules to meet my needs. However, the WFR will only fire when the account record is updated and I need a trigger to evaluate realtime. Unfortunately, I do not understand Apex, but I am starting to learn.
What I am trying to accomplish, is simply return two fields to Null when a date field = Today()
SIS_Status__c (Picklist)
Coma_until__c (Date field)
Dead_until__c (Date field)
The basic scenario is a sales rep will set the SIS_Status__c field located in the account record to coma or dead. Then, they will populate the date (Coma_Until__c and/or Dead_Until__c) when SIS_Status__c should be reset to Null. When Today() = the date entered in the date field, it will reset the SIS field.
Here are the three possible scenarios:
Senario 1:
SIS_Status__c = Dead
Dead_Until__c = 5/1/14
Coma_Until__c = 5/1/15
Under this scenario, when today's date = 5/1/14, it will make Dead_Until__c = null and change SIS_Status__c = Coma. Then when today's date = 5/1/15, it will change Coma_Until__C = null and SIS_Status__c = null.
Senario 2:
SIS_Status__c = Dead
Dead_Until__c = 5/1/14
Coma_Until__c = Null
Under this scenario, when today's date = 5/1/14, it will make Dead_Until__c = null and change SIS_Status__c = Null.
Senario 3:
SIS_Status__c = Coma
Dead_Until__c = Null
Coma_Until__c = 5/1/14
Under this scenario, when today's date = 5/1/14, it will make Coma_Until__c = null and change SIS_Status__c = Null.
If someone has a template trigger I could use to go off of or help me write this trigger, I would really appreciate the help!
Cheers!
Ah, I understand what you mean now by creating the formula fields. This would work, but eventually, a sales person would have to go back to the original Sales SIS to update it. So, saving the data is not necessary. I don't know if this solution would totally work beacuse I need the original Sales fields to be updated somehow.
For instance with your solution I have:
Calculated SIS Status Coma
Calculated Dead = Null
Calculated Coma = 3/12/2014
Sales SIS Status = Coma
Sales Dead = Null
Sales Coma = 3/12/2014
I could write the formula so that a Dead/Coma status would populate in the calculated SIS Status when the Calculated Dead/Coma dates are populated. But the Sales data would remain in there. It is imperative that the data is updated beacuse the SIS Status field has other statuses (Prospect, Qualified, etc.).
Cheers!