Include link to approval from change workflow notification

samadam
Kilo Sage

I have a notification generated from rejection of an approval related to change. How can I include link to Approval record in the email. For change link I used ${URI_REF} but not sure how to access the Approval record.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

so notification is triggering from workflow on CHG table.

2 ways

1) To show link to approval record you will have to use email script in workflow notification activity

<mail_script>
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.query();
if (gr.next()) {
var sysId = gr.sys_id;
var tableName = 'sysapproval_approver'; // table name
var instance_name = gs.getProperty('glide.servlet.uri');
template.print('Click here <a href="' + instance_name + tableName  +'.do?sys_id="' + sysId + '">' + 'Approval Record' + '</a>');
}
</mail_script>

See how you can add that below

AnkurBawiskar_1-1744082580562.png

 

OR Another Approach

2) you can use run script to store the link in workflow scratchpad and then use that workflow scratchpad in message of workflow notification activity

Run Script:

var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.query();
if (gr.next()) {
    var instance_name = gs.getProperty('glide.servlet.uri');
    workflow.scratchpad.approvalLink = 'Click <a href="' + instance_name + tableName + '.do?sys_id="' + taskID + '">' + taskNum + '</a> to view the Task.';
}

Then use this in workflow notification message part

${workflow.scratchpad.approvalLink}

Here in below image use ${workflow.scratchpad.approvalLink} to show that link

AnkurBawiskar_0-1744082529626.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

4 REPLIES 4

Jordan Vignoni
Tera Guru

If your notification is on the change_request table, you could try the following URL in your notification to get to the approval record:

/nav_to.do?uri=sysapproval_approver.do?sysparm_query=sysapproval.number=${number}

Its notification in the workflow not created on the table itself

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

so notification is triggering from workflow on CHG table.

2 ways

1) To show link to approval record you will have to use email script in workflow notification activity

<mail_script>
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.query();
if (gr.next()) {
var sysId = gr.sys_id;
var tableName = 'sysapproval_approver'; // table name
var instance_name = gs.getProperty('glide.servlet.uri');
template.print('Click here <a href="' + instance_name + tableName  +'.do?sys_id="' + sysId + '">' + 'Approval Record' + '</a>');
}
</mail_script>

See how you can add that below

AnkurBawiskar_1-1744082580562.png

 

OR Another Approach

2) you can use run script to store the link in workflow scratchpad and then use that workflow scratchpad in message of workflow notification activity

Run Script:

var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.query();
if (gr.next()) {
    var instance_name = gs.getProperty('glide.servlet.uri');
    workflow.scratchpad.approvalLink = 'Click <a href="' + instance_name + tableName + '.do?sys_id="' + taskID + '">' + taskNum + '</a> to view the Task.';
}

Then use this in workflow notification message part

${workflow.scratchpad.approvalLink}

Here in below image use ${workflow.scratchpad.approvalLink} to show that link

AnkurBawiskar_0-1744082529626.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

samadam
Kilo Sage

Utilized the mail script in the workflow notification. Thank you.