- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 08:32 AM
We have one catalogue form in that catalogue with one "Specify end date of roles access" Date field, and an email notification should be sent to a specific group based on that date.
Please find the Catalogue form screen shot, This date is always a future date, and only on that date is an email notification sent to the group.
Please help me on this how to do this requirement.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 06:32 AM
Hi @Sravani47,
Try this updated scripts and modified it accordingly.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item', "sys_id_of catalog_item");
gr.query();
while (gr.next()) {
var temp = gr.variables.end_date_of_roles_access.toString();
if (new GlideDateTime(temp).getDate.getNumericValue() == new GlideDateTime(temp).getDate().getNumericValue()) {
// gs.info("RITM Number: "+ gr.number + new GlideDateTime(temp).getDate.getNumericValue() + " - " + new GlideDateTime(temp).getDate().getNumericValue())
gs.eventQueue('Request.RoleRevoke.Enddata', gr, gr.assigned_to.toString()); // fire this events
}
}
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 02:48 AM
Chances that line 6 would run at the exact time when that statement returns true are quite random.
Change it to:
gs.nowDateTime() >== gr.end_date_of_roles_access
Again, would suggest not to run this job every second.
Thanks & Regards,
Vikrant Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 01:14 AM
Hi,
I would recommend adding an encoded query when you are doing a glide record on sc_req_item, to only query the record where the current time is ==> then End date.
This will also be effective to only iterate as many time as required, rather then querying on all active record.
I would also recommend this to run only once a day, off hours, to have less performance impact.
Thanks & Regards,
Vikrant Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 06:32 AM
Hi @Sravani47,
Try this updated scripts and modified it accordingly.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item', "sys_id_of catalog_item");
gr.query();
while (gr.next()) {
var temp = gr.variables.end_date_of_roles_access.toString();
if (new GlideDateTime(temp).getDate.getNumericValue() == new GlideDateTime(temp).getDate().getNumericValue()) {
// gs.info("RITM Number: "+ gr.number + new GlideDateTime(temp).getDate.getNumericValue() + " - " + new GlideDateTime(temp).getDate().getNumericValue())
gs.eventQueue('Request.RoleRevoke.Enddata', gr, gr.assigned_to.toString()); // fire this events
}
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 03:23 AM
Few Catalogue forms , the below code is working.
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('cat_item', 'Sys ID of catalogue item');
gr1.query();
while (gr1.next()) {
if (gr1.variables.end_date_of_roles_access == new GlideDateTime().getDate())
{
gs.eventQueue('Request.RoleRevoke.Enddata', gr1, gr1.assigned_to.toString());
}
}