1

I need to send a notification after one hour from a particular start date. I am using a time based workflow for the same. What I am trying to do right now is that I have created a check box field on my object and my workflow will set this check box field after one hour from the start date. Based on the true or false condition of the check box I am trying to call a method from the trigger. (checking for this check box field to be true in the update trigger). As I am aware that the order of execution of workflow and triggers are different and workflow are executed after the trigger and probably that's why my check box field is still false and I am not able to call the method in my update trigger. If this cant be done using the above approach, is there anything else that I can try using time based workflow for implementing the same scenario.

Any help would be appreciated.

Thanks..

  • 1
    I have used this scenario many times and it works for me always. May be there are some other issue. because when your WF update the checkbox then your trigger will fire so your trigger will always run in that case. – Tushar Sharma May 9 '17 at 8:24
  • Hi Tushar, thanks for the response. The issue is: trigger in not running second time. I can see the check box field marked as true but I am not able to see any trigger logs in the debug log. I saw the debug logs when the trigger ran for the first time and it had the time based trigger information. But it does not run the second time. – user905 May 9 '17 at 9:19
  • did you check for recursive trigger. May be thats the issue. – Tushar Sharma May 9 '17 at 9:38
0

I can't comment so i have to write here, did you use after or before update trigger? Try using After Update trigger and then check if Trigger.New checkbox value equals true or false.

You can also try using process builder to schedule notification 1 hour after record creation. If you need this only on record creation, if you need this on update also, you can use this on edit and check criteria for your checkbox value, and after sending notification change checkbox to original value.

How to add time-dependent actions in Lightning Process Builder?

|improve this answer|||||
  • Hi LinQ, Thanks for your answer. I have used after insert and after update trigger. I have not tried the process builder approach yet. Right not I wanna figure out why the trigger is not being triggered the second time. When the trigger is called the first time the value for the field is false, but it should be true when its being called the second time. – user905 May 9 '17 at 9:58
0

This can be solved by using 2 workflow on the object ( lets take Opportunity as an example here) and a custom checkbox field. Follow the below steps to execute the requirement:

  1. At opportunity create a custom checkbox field "Sent_Mail__c" default value is False.
  2. Create a workflow "Send Email To Notify Opp Created" (lets say). Object Opportunity, Evaluation Criteria : "Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria" , Rule Criteria : Opportunity: Created Date GREATER THAN 5/9/2016 [here set your specified date u need i.e. from which date you want to send the notification] . Immediate Workflow Actions: Email Alert [set the details for sending the email alert along with email template based on your requirement]. Add Time-Dependent Workflow Actions (0 Days After Opportunity: Created Date) : Field to Update Opportunity: Sent Mail , New Field Value True, Re-evaluate Workflow Rules after Field Change : False

  3. Create 2nd workflow rule "Uncheck The Sent Email ChkBox", Object Opportunity, Evaluation Criteria : "Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria" , Rule Criteria :Opportunity: Sent Mail EQUALS True , Time-Dependent Workflow Actions (1 Hour After Opportunity: Last Modified Date) : Field to Update Opportunity: Sent Mail , New Field Value False , Re-evaluate Workflow Rules after Field Change : False.

Here the 1st workflow is used to send the mail and 2nd workflow is used to uncheck the "Send Mail" checkbox after every 1 hour. There by the record get updated every 1 hour and the mail is triggered. PS: do not keep the "Sent_Mail__c" in the page layout. Else the end user will update it and can hamper the functionality.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.