How do I get an RITM field to show on the approval email?

nadzm
Giga Contributor

We have several Service Catalog items that require an approval before the request is progressed. However I have noticed that the approval email that gets sent out does not contain the 'Requested for' user details. These details are on the RITM ticket and I cant figure out how to display them on the email template. I have tried to amend the email template   'change.itil.approve.role' by dot walking with no luck....

anyone know how I can do this?

1 ACCEPTED SOLUTION

alan_lowrance
Mega Guru

If the approval is coming from the Requested Item, to get any variables from the RITM you need to use sysapproval field to reference the RITM from the approval.   For instance, on the approval's email template, you'd use ${sysapproval.short_description} and ${sysapproval.description}.   Remember variables must be encapsulated with ${} on templates.   But the 'Requested For' actually is stored on the REQ so you need to dot-walk one more level: ${sysapproval.request.requested_for}


View solution in original post

6 REPLIES 6

alan_lowrance
Mega Guru

If the approval is coming from the Requested Item, to get any variables from the RITM you need to use sysapproval field to reference the RITM from the approval.   For instance, on the approval's email template, you'd use ${sysapproval.short_description} and ${sysapproval.description}.   Remember variables must be encapsulated with ${} on templates.   But the 'Requested For' actually is stored on the REQ so you need to dot-walk one more level: ${sysapproval.request.requested_for}


Thanks!


In order to use the same template for all my approvals, both manual and automated, I have a mailscript I use so that it makes the correct references for me.   I just have a line on the template where I invoke the mailscript: ${mail_script:approvalTree} which is now stored in its own Notification Email Scripts section.


approvalTree();


function approvalTree(){


if (current.sysapproval.sys_class_name == "sc_task"){


  template.print("Request Item: " + current.sysapproval.request_item.cat_item.name + "\n");


  template.print("Requested For: " + current.sysapproval.request_item.request.requested_for.getDisplayValue());


}


if (current.sysapproval.sys_class_name == "sc_req_item"){


  template.print("Request Item: " + current.sysapproval.cat_item.name + "\n");


  template.print("Requested For: " + current.sysapproval.request.requested_for.getDisplayValue());


}


if (current.sysapproval.sys_class_name == "pm_project_task")


  template.print("Parent Project: " + current.sysapproval.top_task.number + "- " + current.sysapproval.top_task.short_description);




if (current.sysapproval.sys_class_name == "change_request"){


  template.print("Change Request: " + current.sysapproval.number + "- " + current.sysapproval.short_description + "\n");


  template.print("Item being Changed: " + current.sysapproval.cmdb_ci.name + "\n");


  template.print("Business Owner: " + current.sysapproval.cmdb_ci.owned_by.name + "\n");


  template.print("Requested For: " + current.sysapproval.requested_by.name);


}


if (current.sysapproval.sys_class_name == "change_task"){


  template.print("Change Request: " + current.sysapproval.change_request.number + "- " + current.sysapproval.change_request.short_description + "\n");


  template.print("Item being Changed: " + current.sysapproval.change_request.cmdb_ci.name + "\n");


  template.print("Business Owner: " + current.sysapproval.change_request.cmdb_ci.owned_by.name + "\n");


  template.print("Requested For: " + current.sysapproval.change_request.requested_by.name);


}


}


guhann
Mega Guru

Nadeem,



the template 'change.itil.approve.role' is generic for approvals related to all the processes. So if you are adding code to print the requested_for, it will be fine for approvals related to RITM/REQ where as it may impact the approvals related to CHG or any other processes. So make sure you add a condition to check whether the approval is of RITM/REQ. Try like this,



Create an email notification script with below code,


if(current.sysapproval.getTableName() == 'sc_req_item') {


        template.print('Requested for:'+current.sysapproval.request.requested_for.getDisplayValue());


}



And in the template 'change.itil.approve.role' place the below code in the place where you want the Requested for to be printed.


${mail_script:requested_for}