Flow Design to trigger reminder email and send email to Opened for/Caller - script not working?

Winnie P
Mega Sage

Hello Team,

I created a Flow Design to send out approval email reminders every 7, 14, 30 days etc.  The reminder notifications (using sysApproval table) to the Approver is being sent and is working fine. However, I also need to send the same email to the Caller/Opened for of the Request, this part is not working.  I added a script to the Flow as follows:

find_real_file.png

 

The Request to fetch the Caller or Opened for name from the Request ie:

 

find_real_file.png

I also tried this, which does not work either:

var callerid = fd_data.trigger.current.sysapproval.getDisplayValue();
var gr = new GlideRecord('facilities_request');
gr.addQuery('number' , callerid);
gr.query();
while (gr.next())
{
var callerid = gr.request.caller.sys_id;
}
return callerid;

 

Any assistance would be much appreciated. Thank you.

1 ACCEPTED SOLUTION

Hi,

use this script

I assume you have caller as reference field on table facilities_request

var sysId = fd_data.trigger.current.sys_id;

var rec = new GlideRecord('sysapproval_approver');
rec.get(sysId);

var callerid;
var gr = new GlideRecord('facilities_request');
gr.addQuery('sys_id', rec.sysapproval).addOrCondition('sys_id', rec.document_id);
gr.query();
if(gr.next())
{
	callerid = gr.caller.sys_id;
}
return callerid;

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

flow is on which table?

Regards
Ankur

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

Hello Ankur, it is from the sysApproval table, thank you.

find_real_file.png

Hi,

use this script

I assume you have caller as reference field on table facilities_request

var sysId = fd_data.trigger.current.sys_id;

var rec = new GlideRecord('sysapproval_approver');
rec.get(sysId);

var callerid;
var gr = new GlideRecord('facilities_request');
gr.addQuery('sys_id', rec.sysapproval).addOrCondition('sys_id', rec.document_id);
gr.query();
if(gr.next())
{
	callerid = gr.caller.sys_id;
}
return callerid;

Regards
Ankur

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

Thank you Ankur, your script helped me in the right direction and it worked 🙂