function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TinkuTinku 

Trigger on an Account inactivity

Hey guys,

I need some suggestions on how to write a trigger for this particular criteria.

Scenario is like this: An Account is created.And there is No activity on the account for 3 weeks. (no update, or delete).
I need to write a trigger for this inactivity, on Account. I am stumped because  until and unless there is some action on account, my trigger wont get fired.

so i need some suggestions on how to move forward with this.


Best Answer chosen by Admin (Salesforce Developers) 
gm_sfdc_powerdegm_sfdc_powerde

You could use time-based workflow to update a field on the account, which would fire a trigger that creates a case.   Another option would be running periodic jobs (See Apex scheduler documentation here - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm) that identify inactive accounts using a SOQL and act upon them.

All Answers

kyle.tkyle.t

What is the use case... it sounds like you want to use a time-based workflow.

 

time tirigger would be 21 days after last modified date.

TinkuTinku

Kyle,

 

Sorry, i dint explain the scenario properly. So its like this: if there is no activity on the account for 3 weeks, then i need to create a case.

 

I dont think i can use time-based workflow to create the case.

 

Any other suggestions please.

gm_sfdc_powerdegm_sfdc_powerde

You could use time-based workflow to update a field on the account, which would fire a trigger that creates a case.   Another option would be running periodic jobs (See Apex scheduler documentation here - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm) that identify inactive accounts using a SOQL and act upon them.

This was selected as the best answer
TinkuTinku

Thank you for the suggestion.

 

The time-dependent workflow updates a filed in my account object. And that inturn fires the trigger to create the case.

 

Qucik question though: Any suggestions on using the Batch Apex trigger for the trigger which creates the case. (based on this scenario).