Creating a Scheduled Notification

Felipe Benevid1
Giga Contributor

Good afternoon people,

I am trying to generate a scheduled notification where only the email would be triggered when the date was equal to the date included in a record field.

Example: A notification when the user is birthday.

Is it possible to create a notification like the example above?

Thank you.

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

Hello Felipe


Try something like this


1. system policy> events> registry


Event name: user_birthday


2. System definition>Scheduled jobs


Run: Daily


Script:


var date = "u_birthdayONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)"; // get this encoded query depending on your field on user table


var gr = new GlideRecord('sys_user');


gr.addEncodedQuery(date);


gr.query();


while(gr.next())


{


//gs.log(gr.email ,'prateek_new');


gs.eventQueue("user_birthday",gr, gr.email);


}


3.System Notification>Email> notifications


Name: Your custom name


Table: sys_user


1.When to send


send when: event is fired


event name: user_birthday


2.Who will receive


event parm1 contains recipient: checked


send to event creator: checked


3. What it will contain


Depending on your requirement



Try this out and let me know the results



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

5 REPLIES 5

Somveer Karhan1
Giga Expert

Yes Felipe, that's possible. Highlighting the steps below:



1. Create a custom event in sysevent_register table.


2. Schedule a script execution on daily basis. Script should look for all users in the table who have birthday on the day of script execution. Use Gliderecord and compare the today's date with the date field in table.


3. For every matching record in step 2, generate an event using gs.eventQueue() and pass the user details (email id) as parameter.


4. Create a notification to be sent based on your custom event.



PS: Hit Like, Helpful or Correct based on the impact of this response.


Thank you Somveer,



I will carry out the tests and return with the answer.


harshinielath
Tera Expert

Hi


You can have a scheduled job and write in the script something like this




remindApprovers();  


function remindApprovers(){  


    // remind everyone, all the time?  


    var spamMachine = false;  


     


    var appr = new GlideRecord('sysapproval_approver');  


    if (spamMachine){  


          appr.addQuery('state', 'requested');  


    }  


    else {  


          appr.addEncodedQuery('state=requested^sys_updated_onRELATIVELT@hour@ago@48');   //reminder for approvals requested and not updated in the last 48 hours


    }  


    appr.query();  


    while (appr.next()){  


          gs.eventQueue("event_name", appr, gs.getUserID(), gs.getUserName());  


          gs.log('Re-requested approval of task ' + appr.sysapproval.number + " by " + appr.approver.name);  


    }  


}  


The event has to created with triggering notification.


Prateek kumar
Mega Sage

Hello Felipe


Try something like this


1. system policy> events> registry


Event name: user_birthday


2. System definition>Scheduled jobs


Run: Daily


Script:


var date = "u_birthdayONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)"; // get this encoded query depending on your field on user table


var gr = new GlideRecord('sys_user');


gr.addEncodedQuery(date);


gr.query();


while(gr.next())


{


//gs.log(gr.email ,'prateek_new');


gs.eventQueue("user_birthday",gr, gr.email);


}


3.System Notification>Email> notifications


Name: Your custom name


Table: sys_user


1.When to send


send when: event is fired


event name: user_birthday


2.Who will receive


event parm1 contains recipient: checked


send to event creator: checked


3. What it will contain


Depending on your requirement



Try this out and let me know the results



Please mark my response as correct and helpful if it helped solved your question.
-Thanks