- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 12:12 AM - edited 06-05-2023 12:24 AM
Hello Community!
Trying to use script include in the BCC of Email Client Template.
I am trying to autopopulate the some certain email addresses in Bcc Field of email client Template. For this I have written a script include and calling that script include in the bcc field as shown below. But this script include is not executing for some reason.
I am calling script include on bcc as below:
javascript: new AffectedCISubscribers().AffectedCI();
Script Include:
var AffectedCISubscribers = Class.create();
AffectedCISubscribers.prototype = Object.extendsObject(AbstractAjaxProcessor, {
AffectedCI: function() {
var afc = new GlideRecord("task_ci");
afc.addQuery('task', current.sys_id);
afc.query();
var inc1 = [];
while (afc.next()) {
var inc2 = afc.getValue('ci_item');
inc1.push(inc2);
}
var nof = new GlideRecord("sys_notif_subscription");
nof.addQuery('affected_record', inc1);
nof.query();
var xyz = [];
while (nof.next()) {
xyz.push(nof.user.email);
}
return xyz;
},
type: 'AffectedCISubscribers'
});
I also tried changing the name of the function same as the script include name and then in Bcc I wrote this way
javascript: AffectedCISubscribers();
but even this didn't work.
Please let me know what changes I need to do to make this work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 03:25 AM
Check these things
- If the Email client Template is on correct table or not.
- Also try by passing the sys_id as parameter instead of using current.sys_id.
- Add logs for inc1 and xyz and check the values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 12:45 AM
Try this
var AffectedCISubscribers = Class.create();
AffectedCISubscribers.prototype = Object.extendsObject(AbstractAjaxProcessor, {
AffectedCI: function() {
var afc = new GlideRecord("task_ci");
afc.addQuery('task', current.sys_id);
afc.query();
var inc1 = [];
while (afc.next()) {
var inc2 = afc.getValue('ci_item');
inc1.push(inc2);
}
var nof = new GlideRecord("sys_notif_subscription");
nof.addQuery('affected_record', inc1);
nof.query();
var xyz = [];
while (nof.next()) {
xyz.push(nof.user.email+"");
}
return xyz.join();
},
type: 'AffectedCISubscribers'
});
Calling -
javascript: new AffectedCISubscribers().AffectedCI();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 12:52 AM
I just tried what u have mentioned above. But it is not working.
email client template :
Blank output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 01:01 AM
Can you keep logs in your script include and see the xyz value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 01:29 AM
yeah I did that, I am getting expected list of emails.
&
I am not sure in Bcc of email client template can we use script include or not.