Menu
Welcome, Guest
Username: Password: Remember me
Support for Advanced Open Workflow, Sales, Portal for SugarCRM Community Edition

TOPIC: Triggering an action in the future

Triggering an action in the future 1 week 4 days ago #89118

  • philemery
  • philemery's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 4
  • Karma: 3
I'm wanting to send an email after a specified number of days (3) after the record is created. I would imagine that would be in the Conditions panel.

Can't quite figure out what the correct approach would be.

I have a field that is created that contains a date 3 days after the creation date (date to send). I want the action to trigger on that day, but not before.

So would the condition be:

Run: Only in The Scheduler

Leads->DateToSend->EqualTo->Date->Today

?

I tried to use LessThan or GreaterThan arguments as been suggested but can't get my head around it.
The administrator has disabled public write access.

Triggering an action in the future 1 week 3 days ago #89187

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10932
  • Thank you received: 1635
  • Karma: 371
Suppose you have a field called "TriggerOn" which holds the data where the workflow needs to be triggered.

Then the Workflow would simply look like this:

WorkFlow Module: Contacts

Status: Active

Run: Always

Run On: All Records

Repeated Runs: checked

Conditions:
Contacts TriggerOn Less Than or Equal To Date Now


Now, the problem with this is performance. Every minute, your Workflow will be going through ALL records, checking them one by one, to see if they match. So you should make sure you add more conditions if possible (only some kinds of records, or records created recently, or something). You should also use an auxiliary field "processed" to have more control about the fact that this should only happen once to each record.

But if this still is too bad for performance (depends on how many records you have) you should make a custom scheduler to do this work (as a simple selective query that then makes Bean changes to the required records, which will in turn trigger workflows, but only on those records, not on all of them).

I hope this helps, sorry if it is too complex, I'm hoping the simple version might work for you.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
Last Edit: 1 week 3 days ago by pgr.
The administrator has disabled public write access.

Triggering an action in the future 1 week 3 days ago #89215

  • philemery
  • philemery's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 4
  • Karma: 3
Thanks!

A question, as the date comparison is "less than or equal to", wouldn't this trigger anytime before the send to date?

So if the record (in this case lead) :

creation date: Jan 1, 2019

sendto date: Feb 29, 2019

Wouldn't the workflow trigger on any date "before" Feb 29th?

What if I want the workflow to trigger ON Feb 29th and not before or after?
The administrator has disabled public write access.

Triggering an action in the future 1 week 2 days ago #89243

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10932
  • Thank you received: 1635
  • Karma: 371
With these conditions, I basically try it one way, if it doesn't work, I try the opposite. If that doesn't work either, I scratch my head and wonder why :huh:

But look at it this way: my condition is "if TriggerDate is before now". If you read it the other way around, it's "now is after TriggerDate", which means, the time has come. It works.

About using "equals" instead of "lesser/greater than": if your scheduler for some reason doesn't run on a given day (your server is down, for example) you might skip a record. Or if you change the server's clock. The wider conditions cover this case.

A second case: if a user edits the TriggerDate of a record that was supposed to trigger tomorrow, but moves that date to "yesterday", the "lesser than" will still catch it, whereas the "equal" will miss it.

These are rare cases but I think this way it is more robust. But it requires ensuring that it doesn't run twice. We could use the "repeated runs" feature for that, but it might make it complicated to manage in the cases where we do want to trigger more than once, for some reason (re-send email?). We wouldn't have a way of re-setting the system-managed "has already run" flag.

So I just leave repeated runs checked, making the system ignore repeated runs, and instead I use my own flag, a "processed" field, that I check as a condition (only run if processed = false), then set as an action (after processing, set "processed = true"). If ever I need to reset I just change that field back.

I hope this clarifies things. In case of doubt, just experiment! :)

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
Last Edit: 1 week 2 days ago by pgr.
The administrator has disabled public write access.
Time to create page: 0.069 seconds
Powered by Kunena Forum