+ Start a Discussion

Trigget to update opportunity field when activity is logged

Hi I am trying to create a trigger that will update a field on the opprtunity when an avtivity is logged on an opportunity.


The reason for this is that I want to send out email alerts when an opportunity is inactive or no activity has been done for a period of time. The users usually leave the stage unchanged for a month or two but if they are working on the opportunity they log calls or other activities on the Activity History related list. We want to notify the users if nothing has been logged or the stage has not changed in 2 months and let them know with an email alert that this opportunity is "inactive"


I was thinking of updating a hidden field on the opportunity everytime an activity is recorded then run workflow from that field that will count 2 moths after the last update if nothing has changed then send the email alert? Is this possible the way I'm thinking of doing it? Any help will be appreciated.


Thank you.


Have you considered using a time-dependent workflow based upon the opportunity's LastActivityDate field?


You may also be interested in the Apex Scheduler




I think I gave this some thought but wasnt sure if the ule will work because we are trying to send an email if an opportunity is not being modified within a certan time frame for example if I log a call today and necver go back for a month and dont log another call or edit the opportunity thats when i want to receive an email.


If I do a time-dependent workflow and set the rule criteria to: LastActivityDate = TODAY()




Evaluation Criteria:When a record is created, or when a record is edited and did not previously meet the rule criteria


then the action to 30 days after Rule Trigger Date, will this still work? My concern here is that it will not fire unless  the record is modified we want to do the opposite send the email 30 days after the last activity date or modified date.