- 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 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
}