The CreatorCon Call for Content is officially open! Get started here.

Send reminder 24 hours before

harry24
Tera Contributor

I want to send reminder 24 hrs before the scheduled date to the user without using flow designer .

This is on custom table which has a field called start date .

6 REPLIES 6

The script you mentioned works fine but I am unable to trigger it before 24 hours . Can you help me build the condition , start date is the name of the field and is of type datetime

I would write it this way but you can still tweak this to meet your requirements:

// Query the database for records with Start Date field values at or before 24 hours from now
// But after yesterday to avoid retrieving past records
var grWorkDetailsNeedReminder = new GlideRecord('u_work_details');
grWorkDetailsNeedReminder.addQuery('u_start_date', '<=', 'javascript:gs.endOfTomorrow()');
grWorkDetailsNeedReminder.addQuery('u_start_date', '>', 'javascript:gs.endOfYesterday()');
grWorkDetailsNeedReminder.query();


while(grWorkDetailsNeedReminder.next()){
	gs.info("Work Details record = " + grWorkDetailsNeedReminder.u_number + " with Start Date = " + grWorkDetailsNeedReminder.u_start_date);

	// Trigger your custom event here to send notification
	// First parameter is your custom event name
	// Second parameter is the gliderecord
	// You can also include parm1, parm2, and queue parameters
	gs.eventQueue("u_work_details.reminder", grWorkDetailsNeedReminder);
}

This will run daily at 12 MN. I then queried my table to look for Start Date that is scheduled at or before tomorrow BUT after yesterday to avoid records with past date. It's the same as this filter in my custom table.

All records:

Filtered records:

Trigger your custom event. I created "u_work_details.reminder" event in Event Registry (sysevent_register), you can name it differently.

I then created a Notification (sysevent_email_action) that will be triggered by the same custom event we called in our Scheduled Script.

 

Please let me know if this helps.