Based on the date, an email notification should be sent to a specific group in catalogue form.

Sravani47
Tera Contributor

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.

Sravani47_0-1668615941270.png

 

Please help me on this how to do this requirement.

1 ACCEPTED SOLUTION

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

The world works with ServiceNow

View solution in original post

23 REPLIES 23

🙂 Do it for one RITM. Write gr.setLimit(1); and see the result.

Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma

gs.info("Test set info : "+gr.setLimit(1));

 

Result is undefined

Don't log this, use this at line 3.

Can you share the code you are using?

 

Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma

var gr = new GlideRecord('sc_req_item');
gr.addActiveQuery();
gr.setLimit(1);
gr.query();
while (gr.next()) {
//gs.info("Test info 12345 : "+gr.variables.end_date_of_roles_access.getDisplayValue());
// gs.info("Test suresh 12345 : "+gr.variables.end_date_of_roles_access);
//gs.info("info 1234 now time : "+gs.nowDateTime());
if(gs.nowDateTime() >= gr.variables.end_date_of_roles_access){
gs.eventQueue('Request.RoleRevoke.Enddata', gr, gr.assigned_to.toString());
}

}

 

email not triggered 

This is catalogue variable value - end_date_of_roles_access