- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 10:53 PM
Hi @Hagos ,
You can use the Unicode character for a non-breaking space, which is U+00A0. Here's an example of how you can achieve this in different scenarios:
Excel export with ServiceNow Export Sets or Reports: When exporting data to Excel using ServiceNow Export Sets or Reports, you can include the non-breaking space character within your data fields. For example, if you want to add a non-breaking space after a specific value in a field, you can concatenate the value with the non-breaking space character like this: "Value" + "\u00A0". This will ensure that the space is preserved in Excel.
CSV export with ServiceNow Transform Maps: When exporting data to CSV using ServiceNow Transform Maps, you can utilize the GlideStringUtil API to replace regular spaces with non-breaking spaces before exporting. Here's an example script that demonstrates this:
// Create a CSV string
var csvString = 'Field 1,Field 2,Field 3\nValue 1,Value 2,Value 3';
// Replace spaces with non-breaking spaces
csvString = csvString.replace(/ /g, '\u00A0');
// Create a new attachment record
var attachment = new GlideSysAttachment();
attachment.write('table_name', 'record_sys_id', 'filename.csv', 'text/csv', csvString);
// Attach the file to the record
attachment.setEntryRecord('table_name', 'record_sys_id');
attachment.setEntryID('record_sys_id');
attachment.setContentType('text/csv');
attachment.setFileName('filename.csv');
attachment.attach();
// Optional: Delete the attachment record if needed
attachment.deleteRecord();
Also, refer https://unicode-explorer.com/c/00A0 & https://symbl.cc/en/00A0/
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 10:53 PM
Hi @Hagos ,
You can use the Unicode character for a non-breaking space, which is U+00A0. Here's an example of how you can achieve this in different scenarios:
Excel export with ServiceNow Export Sets or Reports: When exporting data to Excel using ServiceNow Export Sets or Reports, you can include the non-breaking space character within your data fields. For example, if you want to add a non-breaking space after a specific value in a field, you can concatenate the value with the non-breaking space character like this: "Value" + "\u00A0". This will ensure that the space is preserved in Excel.
CSV export with ServiceNow Transform Maps: When exporting data to CSV using ServiceNow Transform Maps, you can utilize the GlideStringUtil API to replace regular spaces with non-breaking spaces before exporting. Here's an example script that demonstrates this:
// Create a CSV string
var csvString = 'Field 1,Field 2,Field 3\nValue 1,Value 2,Value 3';
// Replace spaces with non-breaking spaces
csvString = csvString.replace(/ /g, '\u00A0');
// Create a new attachment record
var attachment = new GlideSysAttachment();
attachment.write('table_name', 'record_sys_id', 'filename.csv', 'text/csv', csvString);
// Attach the file to the record
attachment.setEntryRecord('table_name', 'record_sys_id');
attachment.setEntryID('record_sys_id');
attachment.setContentType('text/csv');
attachment.setFileName('filename.csv');
attachment.attach();
// Optional: Delete the attachment record if needed
attachment.deleteRecord();
Also, refer https://unicode-explorer.com/c/00A0 & https://symbl.cc/en/00A0/
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 12:37 PM
Great! Thanks
this was really helpful