Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Comma Separated Values in Email Script

Poorva Bhawsar
Mega Sage

Hi Community,

 

I have this email script which is pulling affected products in the notification.

 

var gr = new GlideRecord("m2m_kb_ci");
gr.addQuery("kb_knowledge", current.sys_id);
gr.query();
while (gr.next()) {
template.print(gr.getDisplayValue('cmdb_ci'));
}

 

Currently its printing abcxyz. I want to have comma separated values as abc,xyz.

I tried to split it but nothing worked.

Kindly help me in this.

 

Thanks,

Poorva Bhawsar

1 ACCEPTED SOLUTION

Kalyani Jangam1
Mega Sage

Hi @Poorva Bhawsar 

Please try below code, declare one array and push cmdb_ci value on that.

var arr=[];
var gr = new GlideRecord("m2m_kb_ci");
gr.addQuery("kb_knowledge",current.sys_id);
gr.query();
while(gr.next()) {
var num=gr.getDisplayValue('cmdb_ci');
arr.push(num);
}
template.print(arr);

 

Please check and Mark Helpful and Correct if it really helps you.

View solution in original post

3 REPLIES 3

Kalyani Jangam1
Mega Sage

Hi @Poorva Bhawsar 

Please try below code, declare one array and push cmdb_ci value on that.

var arr=[];
var gr = new GlideRecord("m2m_kb_ci");
gr.addQuery("kb_knowledge",current.sys_id);
gr.query();
while(gr.next()) {
var num=gr.getDisplayValue('cmdb_ci');
arr.push(num);
}
template.print(arr);

 

Please check and Mark Helpful and Correct if it really helps you.

Poorva Bhawsar
Mega Sage

Yes that worked for me... Thanks... 🙂

Hi @Poorva Bhawsar 

That's Great!! Please mark Helpful also!!