Question

Custom Event to check records of a table and react to a date field


Userlevel 3
Badge +8

I am looking for help on creating a custom event that will check records that have a date within the next few days and then send an email to a users email address.

Basically if a date is set for an action to be done for a certain order, then email the coordinator.  

If you have ideas please let me know and I can share more info as needed.


3 replies

Userlevel 6
Badge +18

Hi @STMVALENTINE - Since this doesn’t sound like it is really dependent on any specific event trigger,  you would probably want to run this as a scheduled database job so it runs daily, calling an API and using an Argument for the date where it is less than TODAY+3 or whatever threshold you want.

If I had to do this using an Event I would most likely create a custom view that includes “Date until due” value (e.g. 4 = it needs to be done within 4 days from now), and then have an event that runs based on some daily occurrence and use a Condition in the Event Action where the “DAYS_UNTIL_DUE” in the view <=3 or whatever.

I’m sure there are other ways to do this but hopefully this helps get you started

Userlevel 3
Badge +8

Thanks @NickPorter, long time since hearing your name.  Haven’t seen or heard of you since my WNA days.

In any way, yes, I am looking at creating a scheduled database task, but not exactly sure how to get that to send emails with info from the table to specific users.  

Any help or examples would be welcomed...

Userlevel 6
Badge +18

With scheduled database tasks it would depend on exactly what you were wanting to notify on.  If there is an existing API that does the notification, you can typically just call that with the relevant parameters as arguments.  For example, here is a basic config we have to notify users that they have invoices pending their approval, which uses standard ootb API functionality so the parameter is included in the setup of the task and then passes to the background jobs when they run:

 

If there’s no standard API for notification in the area that you need, you could either:

  1. Create and deploy a custom API that does what you need then call that from the task
  2. Create an Event and Event Action as noted before, likely with a custom view and pull the info from that
  3. Create an Application Server task that runs a SQL Query-based Quick Report which selects the data, and have that email the result to a group mailbox, or set up one per person and adjust the report to be unique for each coordinator and hardcode the Email Address to each coordinator… this would be good if you can send all info to a group email but painful to manage though if doing individually.  Something like this for a group send:

     

Reply