Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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