Change Task notification to contain link to Change Request

schrist74
Kilo Explorer

Hi

I'm trying to add the Change Request link to the change_task.itil.role email template so that the recipient of the assigned Change Task is able to click on the Change Task notification link and open the Change Request directly from the email.   At present I've created a Notification Email Script (below) that is successful in generating the link except as it iterates through the script it prints every Change Request number instead of just the same one as the Change Request it came from. Does anyone know how to hone it to only show the parent change request as a link?

***************************************************************************************

ctaskLinks();  

function ctaskLinks() {  

    //Check for any tasks and add links if they exist  

    var gr = new GlideRecord('change_request');  

    //gr.addQuery('change_task', current.sys_id); - created email with all Change Request numbers

//gr.addQuery('change_task', current.change_task.change_request.sys_id);   - as above

//gr.addQuery('change_task', current.change_request.sys_id);   - as above

gr.addQuery('change_task', current.change_task.sys_id);

    gr.query();  

    if(gr.hasNext()){  

          template.print('Change Request: \n');  

          while (gr.next()) {  

                var link = createLinkForTask(gr.getTableName(), gr.sys_id, gr.number);  

                template.print(link + '\n');  

          }  

          template.print('<hr/>');  

    }  

}  

 

function createLinkForTask(strTableName, strSysID, strTaskNumber) {  

    return "<a href=\"" + gs.getProperty("glide.servlet.uri") + gs.generateURL(strTableName, strSysID) + "\">" + strTaskNumber + "</a>";  

}

***************************************************************************************

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Christine,



Please check section 8.2 for more info.


http://wiki.servicenow.com/index.php?title=Email_Notifications#gsc.tab=0


marcguy
ServiceNow Employee
ServiceNow Employee

Click here to view Related Change: ${change_request.URI_REF}


---------------


that's all you should need to do if you want to link to the parent change.


Thank you kindly Pradeep, I'd tried all sorts of variations but not that one!


corjack
Tera Contributor

This worked perfect for me!  Thank you!