Need to add field name dynamically in Subject of notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 07:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 03:50 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 08:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 08:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 08:39 AM
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