How to import excel data into catalog task variables through RITM workflow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 05:21 AM
Hi, I have a requirement for uploading the excel data to catalog task variables once the RITM is submitted. I have to do it from RITM workflow itself and the data has to be loaded to certain catalog task of submitted RITM.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 05:30 AM
You will need to parse the Excel file, create variables from the parsed data and link the variables to catalog tasks. A script like below could help you in the right direction, I am just not sure if it can be done in a workflow
// Assuming 'attachmentSysId' is the Sys ID of the uploaded Excel file attachment
var attachmentSysId = 'your_attachment_sys_id_here';
var attachmentGR = new GlideRecord('sys_attachment');
if (attachmentGR.get(attachmentSysId)) {
var attachmentStream = new GlideSysAttachment().getContentStream(attachmentGR);
var excelParser = new sn_impex.GlideExcelParser();
excelParser.setSheet(attachmentStream, 1);
var row;
while (row = excelParser.getNext()) {
var variableName = row.getCellValue(0); // Assuming variable names are in the first column
var variableValue = row.getCellValue(1); // Assuming variable values are in the second column
// Create variable in the sc_item_option table
var variableGR = new GlideRecord('sc_item_option');
variableGR.initialize();
variableGR.request_item = current.sys_id;
variableGR.item_option_new = variableName;
variableGR.value = variableValue;
variableGR.insert();
// Link variable to a catalog task if needed
// This part depends on how your catalog tasks are structured and linked to RITMs
}
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark