Need to add field name dynamically in Subject of notification

Priyanka77
Tera Guru

Hi,
My requirement is to trigger email for multiple people for below conditions:
There are 4 fields in a table and that 4 refers to sys_user table. Through catalog item if I change any one field then it should send notification to all those people. In subject line I need to give label of that four fields after changes.

For example: Four fields: A,B,C,D
if "A" field changes then in subject line it should show: A(label not the name) has been changed for "x"record.

Please give me some solutions.

Thanks,
Priyanka

8 REPLIES 8

Hi Filipe,

I have tried above script but getting all the values in a subject but i change only one field out of four. Below is the script written in mail script:

Subject should be: A has been changed but its showing A,B,C has been changed

var a = new GlideRecord('table name')

a.getValue('sys_id','sysid of catalog item');

var fields = event.parm1.split(",");

var field_labels =[A,B,C];//label of field

for(var field in fields){

fields.push(a.getLabel(fieldname));//catalog item variable in which that four fields are available as choices

}

email.setSubject("Fields "+field_labels.join(", ")+ "changed");

Can you please check this script and help me here.

 

Thanks,
Priyanka

Sai Kumar B
Mega Sage
Mega Sage

@Priyanka 

1.) Add condition as below

find_real_file.png

2.) Set subject as below

find_real_file.png

3.) You can do the same for other three fields as well by creating another notification

Hi @Sai Kumar,

Thanks for your response.

But at a time only one field will only get change and I need to dynamically add that field name in subject line and only one notification should be created as per the requirement.


Yes you can create different notifications for different fields and set conditions and subject as per the above approach. So, notification will trigger accordingly based on condition.

Or

You can write a script to trigger notification with dynamic subject as suggested by @Filipe Cruz