1 script in multiple email notifications by table.

Steven Young
Tera Guru

Hey again everyone.

I have the need with a large number of email notifications to put a section "for the administrator" on each email notifcation.

Part of that depends on which table an email notification is running on.

With my lack of scripting expertise, i'm looking for help.

I was a script that i can place on the email notifications with the ${mail_script:"name"} function.

I want to be able to say that if a notification is running on the sysapproval table to print certain things.

if its running on the request item table, print certain things.

so like:  

if: table = "value/or sys_id" {

template.print('values')

}

if: table = "value/ or sys_id" {

template.print('values')

}

This gives me the freedom to apply 1 script across EVERY email notification and i can edit it in 1 place.

I dont want to have to create a script for every table to pull certain values into the email notification.

It gives me the ability to say if a specific field is empty, dont template.print.

I tried unsuccessfully to run a vargr script.

i tried a current.sys_class_name  

So with my limited scripting, i'm asking the pros now

Any help will be appreciated.

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would use current.getTableName() to get the name of the table you're on, so:



if (current.getTableName() == 'sysapproval_approver') {


//do approval stuff


}


else {


//do other stuff


}


View solution in original post

4 REPLIES 4

Kalaiarasan Pus
Giga Sage

current.sys_class_name should give you the table name per me. What value is it returning ?


this was giving me an "undefined" result


Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would use current.getTableName() to get the name of the table you're on, so:



if (current.getTableName() == 'sysapproval_approver') {


//do approval stuff


}


else {


//do other stuff


}


Thanks for the Help Brad.   That did exactly what i need.   i can now create 1 ${mail_script:} and apply it across all of my email notifications.