You need to sign in to do that
Don't have an account?
Russell baker 1
Trigger to get Prior value of formula field on opportunity
I have custom formula field return type date name "Last Activity date" on opportunity It is showing me Last Activity date. I want to capture "last to last Activity date". So I create a custom date field name " last to last activity date" and tried to update via workflow with "created and every time edited" and formula evaluated true. formula is <IsChanged (Last_Activity_due_date__c)>
workflow action is field update "Last to Last Activity Date"(Last_to_Last_Activity_Date) date type Date and formula is
<PRIORVALUE(Last_Activity_due_date__c)>
But It is not updating the Last to Last Activity Date field. I am thinking formula field change does not work with workflow. So i think befor trigger can solve my purpose.
Please help me to write a trigger.
workflow action is field update "Last to Last Activity Date"(Last_to_Last_Activity_Date) date type Date and formula is
<PRIORVALUE(Last_Activity_due_date__c)>
But It is not updating the Last to Last Activity Date field. I am thinking formula field change does not work with workflow. So i think befor trigger can solve my purpose.
Please help me to write a trigger.
You can try below trigger for your requirement
trigger trig_update_old_last_activity_date(before update)
{
for(opportunity opp:trigegr.new)
{
opp.Last_to_Last_Activity_Date = trigger.oldmap.get(opp.id).your_lastactivitydate_field_apiname;
}
}
Hope it helps !
No, Its not working. i have poseted below code:
It is not updating Last to last activity date field.
Issue is coming because formula field change does not call any workflow or trigger and this might be the reason field is not getting updated. So may be you need to use some work-flow for updating last activity date field in sfdc and which will call your workflow or trigger and then field will get updated correctly in sfdc.
Thanks.
Russell baker 1,
Set History tracking for Last_Activity_Due_date__c
in trigger
Best Regards,
Amit Ghadage.
Insread of Last_Activity_Due_date__c set history tracking for fields which you are using in formula of Last_Activity_Due_date__c.
and replace Last_Activity_Due_date__c with those fileds in above trigger .
apply same formula in trigger on history (i.e prior to prior values of ) those fields and assign it to Last_Activity_Due_date__c.
Best Regards,
Amit Ghadage.