- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi all,
How can i add 2 spaces between these 2 email_id. I tried the replace method but it didn't work.
expected outcome : ahmed.moh@gmail.co.in, sudars.awar@gmail.co.in
widget_Ankita>>> ahmed.moh@gmail.co.in,sudars.awar@gmail.co.in
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Ankita9793 ,
You can add two spaces between the email addresses by modifying the Array.join() method. Instead of just a comma, you will join the array elements with a comma and two spaces: ',
var delname = 'Moh Ahmed, Sudars awar'; var delnew = delname.split(',').map(function(item) { return item.trim(); }); var delarray = [];for (var i = 0; i < delnew.length; i++) { var getdel = new GlideRecord('sys_user'); getdel.addQuery('name', delnew[i]); getdel.query(); if (getdel.next()) { delarray.push(getdel.email + ''); } }var delempid = delarray.join(', '); // Add two spaces in the join methodgs.print('widget_Ankita>>> ' + delempid); gs.print('del_name>>> ' + delnew);
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
try this
gs.print('widget_Ankita>>> ' + delarray.join(', '));
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
When you need custom formatting (like ,␣␣ with 2 spaces), you should join the array manually instead of relying on the default array-to-string.
gs.print('widget_Ankita>>> ' + delarray.join(', ')); // <-- comma + 2 spaces
So the fix is simply to use .join(', ') instead of printing the raw array
Hope it helps!
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Ankita9793 ,
You can add two spaces between the email addresses by modifying the Array.join() method. Instead of just a comma, you will join the array elements with a comma and two spaces: ',
var delname = 'Moh Ahmed, Sudars awar'; var delnew = delname.split(',').map(function(item) { return item.trim(); }); var delarray = [];for (var i = 0; i < delnew.length; i++) { var getdel = new GlideRecord('sys_user'); getdel.addQuery('name', delnew[i]); getdel.query(); if (getdel.next()) { delarray.push(getdel.email + ''); } }var delempid = delarray.join(', '); // Add two spaces in the join methodgs.print('widget_Ankita>>> ' + delempid); gs.print('del_name>>> ' + delnew);
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
try this
gs.print('widget_Ankita>>> ' + delarray.join(', '));
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
When you need custom formatting (like ,␣␣ with 2 spaces), you should join the array manually instead of relying on the default array-to-string.
gs.print('widget_Ankita>>> ' + delarray.join(', ')); // <-- comma + 2 spaces
So the fix is simply to use .join(', ') instead of printing the raw array
Hope it helps!
Shashank Jain