Copy Data from Excel Attachment and Paste it in a variable for a particular Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2018 10:26 PM
Hi All,
I have a catalog item, where the end user will upload an excel file attachment.
It will automatically capture the data from the excel file and store it in a comma separated format in a variable.
How to achieve this requirement.
Any script or logic will be humbly appreciated.
Thanks and Regards,
Narayan Saha
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2018 11:25 PM
Hi Narayan,
I think you can make use of the below API to parse the excel sheet attached by the end user.
(https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideExcelParserScoped/concept/GlideExcelParserScopedAPI.html)
Hope this helps you Narayan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 12:56 AM
Thanks, athm!
The script looks to be a server-side script.
Need help to populate the data into a service catalog variable.
Regards,
Narayan Saha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 07:23 AM
I got the similar Story on this -- I have a catalog item, where the end user will upload an excel file attachment.
It will automatically capture the data from the excel file and store it in a comma separated format in a variable.
Script for this is :
// changes would be in HTML Template
//for copying data from excel to catalog variable separately in comma form "A, B, C"
// Please replace xyz to field name where you want this script to work
<script>
document.getElementById('xyz').addEventListener('paste', function(event) {
event.preventDefault();
// Get the pasted text
var pastedText = (event.clipboardData || window.clipboardData).getData('text');
var modifiedText = pastedText.replace(/\t+/g, ',');
// Insert the modified text into the name field
var xyzfield = document.getElementById('xyz');
var caretPosition = xyzField.selectionStart;
var currentValue = xyzField.value;
var newValue = currentValue.substring(0, caretPosition) + modifiedText + currentValue.substring(caretPosition);
xyzField.value = newValue;
});
}