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

Chances that line 6 will return true are random,

change it to 

gs.nowDateTime() >== gr.end_date_of_role_access

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

Hi Vikrantsharma,

 

Updated line 6 but not trigger email

if(gs.nowDateTime() >= gr.end_date_of_roles_access)

Can you log the nowDateTime() and gr.end_date_of_roles value and paste it here?

can you try gr.end_date_of_roles_access.getDisplayValue()?

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

Hi Vikrantsharma

gs.info("Info message"+gr.end_date_of_roles_access.getDisplayValue());

Output is:

Info messageundefined

getting value is undefined , how to fix this issue

 

You said this was on the RITM, is there a chance this is a variable then a field? If yes, have you tried gr.variables.end_date_of_roles_access or gr.variables.end_date_of_roles_access.getDisplayValue()?

Have you logged gs.nowDateTime() too?

Try that as well?

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