- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 12:26 AM
In catalog item based on a field lets say Services, i need to populate BCC of email client template.
Services field has cmdb_ci_service table, where each Services i select has subscribed users.
So when i populate this field corresponding subscribed users has to be populated in BCC field.
Any suggestions.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 03:46 AM
Hi @servicenow14710 ,
- You can write an OnChange client script of catalog item field 'Services'.
- Then do a GlideAjax call within client script which will take input as selected Service and return the sys_id/email of all subscribed users.
Subscribed users against a CI is stored in "cmdb_subscriber" table. You can use below code in your script include to get subscribed users of CI.
- In callback function of GlideAjax, you can set the returned value to BCC field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 07:10 AM
Hi @servicenow14710 , If notification is being triggered from "sc_req_item" table then you can simply write an email script to add the subscribers email as below:
// To get the selected service CI subscribed users email
var grUsers = new GlideRecord('cmdb_subscriber');
grUsers.addQuery('item', current.variables.u_services); //u_services is here catalog variable name.
grUsers.query();
while(grUsers.next()) {
email.addAddress('bcc', grUsers.user.email.toString(), grUsers.user.name.toString()); //To Add email adress as bcc
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 03:46 AM
Hi @servicenow14710 ,
- You can write an OnChange client script of catalog item field 'Services'.
- Then do a GlideAjax call within client script which will take input as selected Service and return the sys_id/email of all subscribed users.
Subscribed users against a CI is stored in "cmdb_subscriber" table. You can use below code in your script include to get subscribed users of CI.
- In callback function of GlideAjax, you can set the returned value to BCC field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 04:47 AM
@Pravindra1 :Thanks for the reply, Can you please help how to set bcc from this client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 05:11 AM
Hi @servicenow14710 , If you are looking for send the notifications to these users as 'bcc' then you need to create an email script and call that email script in your Notification template.
use below code in Email Script to Add 'cc' / 'bcc' to email notifications
email.addAddress('cc', 'user@gmail.com', 'User Name');
email.addAddress('bcc', 'user2@gmail.com', ''User Name);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 05:15 AM
@Pravindra1 : I am getting the output in client script, so how i ensure this response goes to email script?