- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 10:06 PM
Hello,
I need to add two email ids as cc whenever notifications are sent. I created a system property to store the email ids and used it in an email script. But when the notification was sent, in the cc it was displayed emailidINCnSR which is the value of my system property. When i tried by putting only one emailid in the value of property, it is showing in cc. But when when i put both the emailids in the value of the property, it doesnot show anybody in cc. Is it a mistake in the system property or the email script? Please help.
Screenshot of system property is as shown:
Email script is as follows:
var tableName = current.getTableName();
if(tableName== 'change_request')
{
var emlid = gs.getProperty('cc.emailid.CHG');
var emaillist =[];
if(emlid)
{
emaillist = emlid.split(',');
email.addAddress('cc',emaillist,'');
}
}
else
if((tableName=='incident')||(tableName=='sc_req_item'))
{
var emailid = gs.getProperty('cc.emailid.INC.SR');
var cclist = [];
if(emailid)
{
cclist = emailid.split(',');
email.addAddress('cc',cclist,'');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 10:49 PM
Well when you split a string it return an array and you have to traverse on that array to access the values. Below modification required
emaillist = emlid.split(',');
for(var i=0; i<emaillist.length; i++){
email.addAddress('cc',emaillist[i],'');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 10:49 PM
Well when you split a string it return an array and you have to traverse on that array to access the values. Below modification required
emaillist = emlid.split(',');
for(var i=0; i<emaillist.length; i++){
email.addAddress('cc',emaillist[i],'');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 11:20 PM
Hello Gurpreet,
The for loop worked, both the email ids are shown in cc. And i had put both the email ids in the 'value' field of system property and kept the 'choices' field blank. And i have also put the 'Type' field as 'choice'.
Just wanted to know whether this is a best practice. Do you know?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 10:51 PM
Hi,
If you have more than two email id stored in property then iterate using for loop to set the address. or else if it is static no of email ids just pass their index after split
eg:
cclist = emailid.split(',');
email.addAddress('cc',cclist[0],cclist[1]);
or
cclist = emailid.split(',');
for(var i=0;i<cclist.length;i++)
{
email.addAddress('cc',cclist[i]);
}
Hope this helps you.
Regards,
Divya Lakshmi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 11:26 PM
Hi divya,
Using the for loop worked, both the emails are shown in cc. I have selected the 'Type' field of system property as 'choice'. What is the difference between selecting it as 'choice' and 'string'?
And also in 'sent' module in navigator will we be able to see the email id of the ones added as cc in the recipient list? I can see the ones in 'To' when i check the 'sent' module but I am not able to see the ones in 'cc'. So, I wanted to know whether this is a normal behaviour.