Use of notification email script to fetch variable

Geeta5
Giga Contributor

Hi Team,

I have  a requirement to trigger a notification.

The notification is created on 'Sysapproval_approver' table.

I have to send this notification to a email id which is present in the 'sc_req_item' form. Variable name in sc_req_item is : 'local_procurement'.

So my notification is getting fired based on condition, it is having the RITM number, how I can write email script to get the value of variable 'local_procurement' and pass this via email  script made calling  on sysapproval_approver table to trigger the notification to that email id(local_procurement).

Please suggest.

 

1 ACCEPTED SOLUTION

Hi Geeta,

in workflow you can use wait for timer activity for waiting and then sending email

You can include schedule as well for excluding weekends

If you are stuck inform the issue.

Please consider marking appropriate reply as Correct & 👍Helpful.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

19 REPLIES 19

Thanks Geeta for the confirmation.

There is a typo for last line

Replace

email.addAddress('CC',procurement);

with

email.addAddress("cc",procurementid,procurementid.getDisplayValue());

 

Tested the same & output as below.

find_real_file.png

Hi Jaspal,

I am still getting undefined in 'cc' . Not sure why, even though in form 'sc_req_item' I have value in local_procurement field(text field).

 

Also, I want to send the notification to this local_procurement with 'TO' option.

Geeta5
Giga Contributor

Also just to add, notification is configured in 'sysapproval_approver' table not in sc_req_item table.

Ntification is getting triggered from flow designer

Hi Jaspal,

I tried with flow designer(has i have to check 'wait for certain time period' and this was easy to do via flow) . But I think my requirement will not be possible via flow designer.

So the requirement is as below :

In 'sc_req_item' form for a catalog I have a variable 'local_procurement' which has email id(ex geeta.dhami@test.com).

Once the request is approved, the state is set to 'On-Hold' and Approval as 'Approved'.

I have to design a job/process, that checks if the state is 'On-Hold' for that request, then wait for 2 weekdays(excluding weekend)  and then send a reminder 1 email to 'Local_Procurement' id.

Then again wait for 2 more days(Weekdays) and then check if still the state is 'On-Hold' , then send reminder 2 email to 'Local_procurement' id.

Again wait for 2 more days(weekdays) and check is state is still 'On-Hold', then mark the state for the request as closed incomplete.

Please suggest.

Alp Utku
Mega Sage

You could use the below script include to push variables to email notification 

 

 	template.print("Summary of Requested items:\n");
    
	var set = new GlideappVariablePoolQuestionSet();
	set.setRequestID(current.getValue('sysapproval'));
	
	set.load();
	
	var vs = set.getFlatQuestions();
		
	for (var i = 0; i < vs.size(); i++) {
				
		if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue()!='' && vs.get(i).getDisplayValue()!='false') {
						
			template.space(4);
			
			template.print(vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br/>");
			
			
		}
		
		
	}