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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Gopal,

You can create custom approval notification for your specific catalog item. Ensure it runs only for your catalog item.

Advanced Condition:

answer = checkCondition();

function checkCondition(){

if(current.sysapproval.cat_item.name == 'Your Catalog Item Name')

return true;

else

return false;

}

Ensure the OOB doesn't trigger for your catalog item

Advanced Condition:

answer = checkCondition();

function checkCondition(){

if(current.sysapproval.cat_item.name != 'Your Catalog Item Name')

return true;

else

return false;

}

Regards
Ankur

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

Hi Ankur,

 

How can I get the fields(catalog item) in the Notification?

 

Can I write the notification on the Catalog item table.

 

Can you explain more?

 

Thanks

Gopal

Hi,

Since you want approval notification you would require notification to be created on sysapproval_approver table

There is out of the box approval notification on that table

Ensure you add condition in it so that it doesn't trigger when approval gets generated for your catalog item or else 2 notifications would be sent. one is OOB and other is your newly created

Also ensure your new notification runs only for your catalog item and not others

Regards
Ankur

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

Hi,

 

Thanks, However how can I add catalog item fields in Notification(Message HTML) in the approval table.