- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 06:34 AM
Hi Experts,
Can someone please help me?
I have a notification email script that queries and prints variables from RITM and field from REQEST table. Since there are lots of RITMS, the client wants to have the stamp bullet and list item, what I have so far is okay except for the Delivery address field in REQUEST table. This field is a string containing value sample below. When it is printed in notification the values are off in spacing. Please see last part for sample.. Can anyone help me please!!
Sample value of field:
Notification Email script: (this is a shortened version of script)
var item = new GlideRecord("sc_req_item");
var cat = item.addQuery("cat_item.category", "d258b953c611227a0146101fb1be7c31"); // Hardware
cat.addOrCondition("cat_item.category", "2c0b59874f7b4200086eeed18110c71f"); //Accessories
item.addQuery("request", current.sys_id);
item.query();
template.print("Summary of Requested items:");
while (item.next()) {
var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 09:50 AM
Hi
You can try removing the newlines (\n,\r) and replacing them with break tags as provided below:
var deliveryAddress = item.request.delivery_address.trim();
deliveryAddress = deliveryAddress.replace(/(?:\r\n|\r|\n)/g, '<br>');
Please try and let me know if you face any issues.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 07:21 AM
Hi,
can you try to trim the spaces?
Did you check how it looks when you print it in background script?
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 09:50 AM
Hi
You can try removing the newlines (\n,\r) and replacing them with break tags as provided below:
var deliveryAddress = item.request.delivery_address.trim();
deliveryAddress = deliveryAddress.replace(/(?:\r\n|\r|\n)/g, '<br>');
Please try and let me know if you face any issues.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 02:51 PM
Thank you Kartik,
This solved my issue! 🙂