Generate Email in Outbox

Suyash Joshi
Tera Contributor

Hello Everyone,

I need a requirement :-

Generate an approval for any table. If the approval state remains 'requested' for 3 days without being approved, send a notification reminder. Additionally, if the approval is still in the 'requested' state after 5 days, check it again, and if it persists, send a remainder notification.

My workflow in which I tried two different script for getting notification

1.By creating a event registry -

gs.eventQueue('demo.notified', current, current.number, gs.getUserName());
2.var currentDate = new GlideDateTime();
currentDate.setDisplayValue(currentDate.getDisplayValue().toString());
var gh = new GlideDateTime();
gh.add(67000);
var gr = new GlideRecord('sc_req_item');
gr.query();
while (gr.next()) {
  gs.eventQueue('demo.notified', current, current.number, gs.getUserName());
}
(It is example for getting notification in few seconds)
but still I'm unable to get the notification message in outbox 
Can anyone solve my issue regarding notification it would really be a great help on urgent basis.
Thanks and Regards,
Suyash
5 REPLIES 5

shyamkumar VK
Kilo Patron

@Suyash Joshi ,

you need to design scheduled Job for this to trigger the notification Periodically , Ideally you need to query the Sysapproval table to get the Records which are in Requested state from Past 3days and then you need to get into the loop to send the reminders for respective source table , Adding Script below 

 

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('state', 'requested');
gr.addQuery('source_table', 'sc_request'); 
gr.addQuery('sys_created_onRELATIVELE@hour@ago@72');
gr.orderBy('approver');
gr.query();
var count = gr.getRowCount();
while (gr.next()) {

    var approver_current = gr.approver;
    gs.eventQueue('demo.notified', gr, gs.getUserID(), approver_current);
    gs.info("Number of Approval Records " + count);
}

 

 

Ensure Notification is on Sc_request table  when to Send condition are configured Properly 

also if you want to do this for different table , just add or condition to the Source table line and design the separate notifications Accordingly

let me know if you need any more information 

Regards, 

Shyamkumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Hi @shyamkumar VK 

But I only want to run the script in workflow can you help via run script?

Regards,

Suyash

@Suyash Joshi  ,

Use Runscript activity and copy the Same script into it

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Hi @shyamkumar VK ,

Sorry for the inconvenience it is not working but one think I wanna ask it is possible to get the requirement without scheduled job?

Regards,

Suyash