Is it possible to create a custom approval notification based on the service catalog item?

Gopal14
Tera Contributor

Hi,

 

Is it possible to create a custom approval notification based on the service catalog item?

 

Ex: 

The workflow for the catalog item XXXX Form includes an approval. When the approval is generated, I want to include the fields in the catalog item in the approval notification that is sent, including the Approve and Reject buttons.

 

1 ACCEPTED SOLUTION

Hi,

For RITM fields you can use this

Example below

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('Catalog Item: ' + current.sysapproval.cat_item.name);

})(current, template, email, email_action, event);

For printing RITM variables use this

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('RITM Variables: <br/>');
    
    var variables = current.sysapproval.variables.getElements();
    for (var i=0;i<variables.length;i++) {
        var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
        if(label != ''){
            template.space(4);
            template.print('  ' + label + " = " + value + "<br/>");
        }
    }

})(current, template, email, email_action, event);

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Hi,

For RITM fields you can use this

Example below

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('Catalog Item: ' + current.sysapproval.cat_item.name);

})(current, template, email, email_action, event);

For printing RITM variables use this

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('RITM Variables: <br/>');
    
    var variables = current.sysapproval.variables.getElements();
    for (var i=0;i<variables.length;i++) {
        var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
        if(label != ''){
            template.space(4);
            template.print('  ' + label + " = " + value + "<br/>");
        }
    }

})(current, template, email, email_action, event);

Regards
Ankur

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

@Gopal 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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