diff --git a/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_556a63b8c3243210d9d679ec05013122.xml b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_556a63b8c3243210d9d679ec05013122.xml new file mode 100644 index 0000000..c8d69d7 --- /dev/null +++ b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_556a63b8c3243210d9d679ec05013122.xml @@ -0,0 +1,2431 @@ + + + public + + + + true + + {labelCacheCleanUpExecuted=true} + 28000 + false + + + + Accepts an attachment sys_id, validates the file (.xlsx/.csv), and returns the parsed data from all sheets as a structured JSON string and a status message. + + false + parseexcelattachmenttojsonmultisheet + [{"name":"{{action.attachment_id}}","label":"action➛Attachment ID","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.attachment_sysid}}","label":"action➛Attachment ID","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].jsondatastring}}","label":"step➛Parse Attachment Content➛jsondatastring","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}},{"name":"{{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].resultmessage}}","label":"step➛Parse Attachment Content➛resultmessage","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}}] + 19acab7cc3243210d9d679ec05013104 + + Parse Excel Attachment to JSON (Multi-Sheet) + + + + false + published + sys_hub_action_type_definition + viraj.hudlikar + 2025-10-10 14:32:03 + global + / + 556a63b8c3243210d9d679ec05013122 + 5 + Parse Excel Attachment to JSON (Multi-Sheet) + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + sys_hub_action_type_definition_556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:41:55 + false + + + + + + sys_hub_action_type_definition + 556a63b8c3243210d9d679ec05013122 + 3 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:38:40 + 06eb2b3cc3243210d9d679ec050131b7 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + 0 + 0eeb2b3cc3243210d9d679ec050131a8 + + + sys_hub_action_type_definition + 556a63b8c3243210d9d679ec05013122 + 1 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:38:40 + c6eb2b3cc3243210d9d679ec050131b7 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + {"version":"1.0","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"794bc342-9c9d-444b-a3f2-dd4b6a5a0173\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"serializationFormat":"JSON","complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":""}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + 06eb2b3cc3243210d9d679ec050131a0 + + + + json_data + 556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:38:40 + 82eb2b3cc3243210d9d679ec050131b7 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122
+ {{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].jsondatastring}} +
+ + resultmessage + 556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:38:40 + 4aeb2b3cc3243210d9d679ec050131b6 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122
+ {{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].resultmessage}} +
+ + __action_status__ + 556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:38:40 + ceeb2b3cc3243210d9d679ec050131b6 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122
+ +
+ + __dont_treat_as_error__ + 556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:38:40 + 0eeb2b3cc3243210d9d679ec050131b6 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122
+ +
+ + + 556a63b8c3243210d9d679ec05013122 + 020f3186-bd7e-4dc8-b92c-23d71a94d013 + 1 + + + + + + + 1 + +
+ 106afb6647032200b4fad7527c9a71e7 + viraj.hudlikar + 2025-10-10 14:38:39 + 71eb2b3cc3243210d9d679ec05013187 + 1 + b812ceb69337a210633378917cba10bc + viraj.hudlikar + 2025-10-10 14:38:39 + + + + sys_hub_step_instance + 71eb2b3cc3243210d9d679ec05013187 + 600 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:38:39 + 4aeb2b3cc3243210d9d679ec0501319c + 0 + viraj.hudlikar + 2025-10-10 14:38:39 + (function execute(inputs, outputs) { + outputs.jsondatastring = ''; + outputs.resultmessage = 'Processing started...'; + + var attachmentSysId = inputs.attachmentSysId; + // This array will hold the results, potentially one object per sheet. + var allSheetData = []; + var totalRecords = 0; + + // 1. Retrieve Attachment Record and Metadata + var attGR = new GlideRecord('sys_attachment'); + if (!attGR.get(attachmentSysId)) { + outputs.resultmessage = 'Error: Attachment not found for sys_id: ' + attachmentSysId; + return; + } + + var fileName = attGR.file_name.toLowerCase(); + var mimeType = attGR.content_type.toLowerCase(); + + var isExcel = fileName.endsWith('.xlsx') && mimeType.indexOf('sheet') > -1; + var isCSV = fileName.endsWith('.csv') || mimeType.indexOf('csv') > -1 || mimeType.indexOf('text') > -1; + + try { + // === OPTION 1: Dedicated GlideExcelParser for true .xlsx files (Multi-Sheet Logic) === + if (isExcel) { + + var attachment = new GlideSysAttachment(); + var attachmentStream = attachment.getContentStream(attachmentSysId); + + if (!attachmentStream) { + outputs.resultmessage = 'Error: Could not retrieve content stream for the Excel attachment.'; + return; + } + + var parser = new sn_impex.GlideExcelParser(); + parser.setSource(attachmentStream); + + var sheetNames = parser.getSheetNames(); + + // Loop through ALL sheet names found in the Excel file + for (var s = 0; s < sheetNames.length; s++) { + var currentSheetName = sheetNames[s]; + var sheetRecords = []; + + parser.setSheetName(currentSheetName); + + if (parser.parse()) { + var headers = parser.getColumnHeaders(); + + while (parser.next()) { + var rowData = parser.getRow(); + var jsonRow = {}; + + for (var i = 0; i < headers.length; i++) { + var header = headers[i]; + var jsonKey = header.replace(/[^a-zA-Z0-9_]/g, '').trim(); + jsonRow[jsonKey] = rowData[header]; + } + sheetRecords.push(jsonRow); + totalRecords++; + } + + // Add the processed sheet to the final output array + allSheetData.push({ + "SheetName": currentSheetName, + "Records": sheetRecords + }); + + } else { + // Log error for a specific sheet but continue parsing others + gs.warn("Error parsing sheet " + currentSheetName + ": " + parser.getErrorMessage()); + } + } + + // === OPTION 2: String Parsing for CSV files (Single Sheet Logic) === + // Note: For the CSV files you attached, they represent only ONE sheet (the file itself) + } else if (isCSV) { + var sheetRecords = []; + var contentBytes = new GlideSysAttachment().getContent(attGR); + var csvString = String(contentBytes); + + var lines = csvString.replace(/\r/g, '').split('\n'); + + if (lines.length < 2) { + outputs.resultmessage = 'Error: CSV file is empty or contains only a header line.'; + return; + } + + var headers = lines[0].split(','); + var sanitizedHeaders = []; + for (var h = 0; h < headers.length; h++) { + sanitizedHeaders.push(headers[h].trim().replace(/[^a-zA-Z0-9_]/g, '')); + } + + for (var i = 1; i < lines.length; i++) { + var currentLine = lines[i].trim(); + if (currentLine === '') continue; + + var values = currentLine.split(','); + var jsonRow = {}; + + for (var j = 0; j < sanitizedHeaders.length; j++) { + var key = sanitizedHeaders[j]; + jsonRow[key] = (values[j] || '').trim(); + } + + sheetRecords.push(jsonRow); + totalRecords++; + } + + // Add the single CSV file result to the final output array + allSheetData.push({ + "SheetName": "Single_CSV_Sheet", + "Records": sheetRecords + }); + + } else { + outputs.resultmessage = 'Error: Unsupported file format. File Name: ' + attGR.file_name; + return; + } + + // 3. Set Success Outputs + // The final JSON string is now an array containing sheet objects. + outputs.jsondatastring = JSON.stringify(allSheetData); + outputs.resultmessage = 'Success: ' + totalRecords + ' records parsed across ' + allSheetData.length + ' sheets from file: ' + attGR.file_name; + + } catch (ex) { + outputs.resultmessage = 'A critical scripting exception occurred: ' + ex.getMessage(); + } + +})(inputs, outputs); + 71aa7f6647032200b4fad7527c9a719b + + + sys_hub_step_instance + 71eb2b3cc3243210d9d679ec05013187 + 400 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:38:39 + 86eb2b3cc3243210d9d679ec0501319c + 0 + viraj.hudlikar + 2025-10-10 14:38:39 + 35aa573fd7802200bdbaee5b5e610375 + f5e56d79b3101300176b051a16a8dce4 + + + + application + 71eb2b3cc3243210d9d679ec05013187 + viraj.hudlikar + 2025-10-10 14:38:39 + 42eb2b3cc3243210d9d679ec0501319c + 0 + viraj.hudlikar + 2025-10-10 14:38:39 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + attachmentSysId + 71eb2b3cc3243210d9d679ec05013187 + viraj.hudlikar + 2025-10-10 14:38:39 + 82eb2b3cc3243210d9d679ec0501319d + 0 + viraj.hudlikar + 2025-10-10 14:38:39 + var__m_sys_hub_step_ext_input_71eb2b3cc3243210d9d679ec05013187
+ {{action.attachment_sysid}} +
+ + script + 71eb2b3cc3243210d9d679ec05013187 + viraj.hudlikar + 2025-10-10 14:38:39 + 06eb2b3cc3243210d9d679ec0501319c + 0 + viraj.hudlikar + 2025-10-10 14:38:39 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String + false + + + + + + + + + + + + + false + false + + + + attachmentSysId + false + + + + false + + + string + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=aac94d33-ef73-42f3-a718-9695d163abd6 + false + + + + + + + + + + + + + false + false + + + + resultmessage + false + + + + false + + + string + + false + 8000 + 71eb2b3cc3243210d9d679ec05013187 + 71eb2b3cc3243210d9d679ec05013187 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_71eb2b3cc3243210d9d679ec05013187 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + viraj.hudlikar + 2025-10-10 14:38:39 + 39eb2b3cc3243210d9d679ec0501318f + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=c402e939-bede-49eb-b5bf-99cee908099c + false + + + + + + + + + + + + + false + false + + + + jsondatastring + false + + + + false + + + string + + false + 8000 + 71eb2b3cc3243210d9d679ec05013187 + 71eb2b3cc3243210d9d679ec05013187 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_71eb2b3cc3243210d9d679ec05013187 + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + viraj.hudlikar + 2025-10-10 14:38:39 + f1eb2b3cc3243210d9d679ec05013193 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + false + false + false + false + false + simple + false + script + + + false + + + + jsondatastring + + + + en + var__m_sys_hub_step_ext_output_71eb2b3cc3243210d9d679ec05013187 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:39 + 4aeb2b3cc3243210d9d679ec05013195 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + + + + + resultmessage + + + + en + var__m_sys_hub_step_ext_output_71eb2b3cc3243210d9d679ec05013187 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:39 + b5eb2b3cc3243210d9d679ec05013192 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=09bc19ab-b8ce-4b6c-841c-b288c3a88d72 + false + + + + + + + + + + + + + false + false + + + + attachment_sysid + false + + + + false + + + string + + true + 8000 + 556a63b8c3243210d9d679ec05013122 + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_definition + var__m_sys_hub_action_input_556a63b8c3243210d9d679ec05013122 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + viraj.hudlikar + 2025-10-10 14:38:39 + 71eb233cc3243210d9d679ec0501316c + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,co_type_name=FDACTIONSTATUS,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=object,uiTypeLabel=Object,uiUniqueId=7947ce24-f4b3-4cde-ac86-20db6c3ebb86 + false + + + + + + + + + + + + + false + false + + + + __action_status__ + + false + + + + false + + + + string + + false + 65000 + 556a63b8c3243210d9d679ec05013122 + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_definition + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:38:39 + 06eb2b3cc3243210d9d679ec050131a0 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=af32d0ab-f671-49f2-aa8b-e07d057fccb7 + false + + + + + + + + + + + + + false + false + + + + resultmessage + + false + + + + false + + + + string + + false + 8000 + 556a63b8c3243210d9d679ec05013122 + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_definition + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:38:40 + 0aeb2b3cc3243210d9d679ec050131ae + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:40 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=e618bf6c-f5a6-4a77-8d34-ce2cccaddcf7,visible_in_ui=false + false + + + + + + + + true + + + + + false + false + + + + __dont_treat_as_error__ + + false + + + + false + + + + boolean + + false + 40 + 556a63b8c3243210d9d679ec05013122 + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_definition + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:38:39 + 0eeb2b3cc3243210d9d679ec050131a8 + 3 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:53 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=489e7feb-7b03-41d4-a3d5-df69dec341f4 + false + + + + + + + + + + + + + false + false + + + + json_data + + false + + + + false + + + + string + + false + 8000 + 556a63b8c3243210d9d679ec05013122 + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_definition + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:38:39 + 4eeb2b3cc3243210d9d679ec050131a4 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + false + false + false + false + false + simple + false + script + + + false + + + + + + + 556a63b8c3243210d9d679ec05013122 + viraj.hudlikar + 2025-10-10 14:38:40 + c2eb2b3cc3243210d9d679ec050131b9 + 0 + viraj.hudlikar + 2025-10-10 14:38:40 + + + + attachment_sysid + + + + en + var__m_sys_hub_action_input_556a63b8c3243210d9d679ec05013122 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:39 + 3deb233cc3243210d9d679ec0501316f + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + + + + + + __action_status__ + + + + en + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:39 + 02eb2b3cc3243210d9d679ec050131a4 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + + + + + resultmessage + + + + en + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:40 + 8aeb2b3cc3243210d9d679ec050131b1 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:40 + + + + + __dont_treat_as_error__ + + + + en + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:40 + caeb2b3cc3243210d9d679ec050131ad + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:40 + + + + + json_data + + + + en + var__m_sys_hub_action_output_556a63b8c3243210d9d679ec05013122 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:38:39 + ceeb2b3cc3243210d9d679ec050131a7 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:38:39 + + + + + + + 556a63b8c3243210d9d679ec05013122 + {"type":"PlanProxy","persistor":{"@class":".ChunkingPlanPersistor","table":"sys_hub_action_plan","id":"7dacab7cc3243210d9d679ec05013173","name":"plan","plan_signature":null}} + e1acab7cc3243210d9d679ec05013141 + viraj.hudlikar + 2025-10-10 14:41:55 + global + / + 7dacab7cc3243210d9d679ec05013173 + 0 + + + viraj.hudlikar + 2025-10-10 14:41:55 + + + public + + + + + {labelCacheCleanUpExecuted=true} + 28000 + false + + + + Accepts an attachment sys_id, validates the file (.xlsx/.csv), and returns the parsed data from all sheets as a structured JSON string and a status message. + + parseexcelattachmenttojsonmultisheet + [{"name":"{{action.attachment_id}}","label":"action➛Attachment ID","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.attachment_sysid}}","label":"action➛Attachment ID","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].jsondatastring}}","label":"step➛Parse Attachment Content➛jsondatastring","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}},{"name":"{{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].resultmessage}}","label":"step➛Parse Attachment Content➛resultmessage","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}}] + true + Parse Excel Attachment to JSON (Multi-Sheet) + + + + 556a63b8c3243210d9d679ec05013122 + sys_hub_action_type_snapshot + viraj.hudlikar + 2025-10-10 14:41:54 + global + / + 19acab7cc3243210d9d679ec05013104 + 0 + + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + + + + + + sys_hub_action_type_snapshot + 19acab7cc3243210d9d679ec05013104 + 1 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:41:54 + 25acab7cc3243210d9d679ec0501313f + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + {"version":"1.0","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"794bc342-9c9d-444b-a3f2-dd4b6a5a0173\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"serializationFormat":"JSON","complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":""}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + 65acab7cc3243210d9d679ec05013128 + + + sys_hub_action_type_snapshot + 19acab7cc3243210d9d679ec05013104 + 3 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:41:54 + 61acab7cc3243210d9d679ec0501313f + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + 0 + e9acab7cc3243210d9d679ec05013130 + + + + json_data + 19acab7cc3243210d9d679ec05013104 + viraj.hudlikar + 2025-10-10 14:41:54 + edacab7cc3243210d9d679ec0501313e + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104
+ {{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].jsondatastring}} +
+ + resultmessage + 19acab7cc3243210d9d679ec05013104 + viraj.hudlikar + 2025-10-10 14:41:54 + a5acab7cc3243210d9d679ec0501313e + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104
+ {{step[020f3186-bd7e-4dc8-b92c-23d71a94d013].resultmessage}} +
+ + __action_status__ + 19acab7cc3243210d9d679ec05013104 + viraj.hudlikar + 2025-10-10 14:41:54 + 2dacab7cc3243210d9d679ec0501313e + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104
+ +
+ + __dont_treat_as_error__ + 19acab7cc3243210d9d679ec05013104 + viraj.hudlikar + 2025-10-10 14:41:54 + 69acab7cc3243210d9d679ec0501313e + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104
+ +
+ + + 19acab7cc3243210d9d679ec05013104 + 020f3186-bd7e-4dc8-b92c-23d71a94d013 + 1 + + + + + + + 1 + +
+ 106afb6647032200b4fad7527c9a71e7 + viraj.hudlikar + 2025-10-10 14:41:54 + 2dacab7cc3243210d9d679ec0501310f + 1 + b812ceb69337a210633378917cba10bc + viraj.hudlikar + 2025-10-10 14:41:54 + + + + sys_hub_step_instance + 2dacab7cc3243210d9d679ec0501310f + 600 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:41:54 + a9acab7cc3243210d9d679ec05013124 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + (function execute(inputs, outputs) { + outputs.jsondatastring = ''; + outputs.resultmessage = 'Processing started...'; + + var attachmentSysId = inputs.attachmentSysId; + // This array will hold the results, potentially one object per sheet. + var allSheetData = []; + var totalRecords = 0; + + // 1. Retrieve Attachment Record and Metadata + var attGR = new GlideRecord('sys_attachment'); + if (!attGR.get(attachmentSysId)) { + outputs.resultmessage = 'Error: Attachment not found for sys_id: ' + attachmentSysId; + return; + } + + var fileName = attGR.file_name.toLowerCase(); + var mimeType = attGR.content_type.toLowerCase(); + + var isExcel = fileName.endsWith('.xlsx') && mimeType.indexOf('sheet') > -1; + var isCSV = fileName.endsWith('.csv') || mimeType.indexOf('csv') > -1 || mimeType.indexOf('text') > -1; + + try { + // === OPTION 1: Dedicated GlideExcelParser for true .xlsx files (Multi-Sheet Logic) === + if (isExcel) { + + var attachment = new GlideSysAttachment(); + var attachmentStream = attachment.getContentStream(attachmentSysId); + + if (!attachmentStream) { + outputs.resultmessage = 'Error: Could not retrieve content stream for the Excel attachment.'; + return; + } + + var parser = new sn_impex.GlideExcelParser(); + parser.setSource(attachmentStream); + + var sheetNames = parser.getSheetNames(); + + // Loop through ALL sheet names found in the Excel file + for (var s = 0; s < sheetNames.length; s++) { + var currentSheetName = sheetNames[s]; + var sheetRecords = []; + + parser.setSheetName(currentSheetName); + + if (parser.parse()) { + var headers = parser.getColumnHeaders(); + + while (parser.next()) { + var rowData = parser.getRow(); + var jsonRow = {}; + + for (var i = 0; i < headers.length; i++) { + var header = headers[i]; + var jsonKey = header.replace(/[^a-zA-Z0-9_]/g, '').trim(); + jsonRow[jsonKey] = rowData[header]; + } + sheetRecords.push(jsonRow); + totalRecords++; + } + + // Add the processed sheet to the final output array + allSheetData.push({ + "SheetName": currentSheetName, + "Records": sheetRecords + }); + + } else { + // Log error for a specific sheet but continue parsing others + gs.warn("Error parsing sheet " + currentSheetName + ": " + parser.getErrorMessage()); + } + } + + // === OPTION 2: String Parsing for CSV files (Single Sheet Logic) === + // Note: For the CSV files you attached, they represent only ONE sheet (the file itself) + } else if (isCSV) { + var sheetRecords = []; + var contentBytes = new GlideSysAttachment().getContent(attGR); + var csvString = String(contentBytes); + + var lines = csvString.replace(/\r/g, '').split('\n'); + + if (lines.length < 2) { + outputs.resultmessage = 'Error: CSV file is empty or contains only a header line.'; + return; + } + + var headers = lines[0].split(','); + var sanitizedHeaders = []; + for (var h = 0; h < headers.length; h++) { + sanitizedHeaders.push(headers[h].trim().replace(/[^a-zA-Z0-9_]/g, '')); + } + + for (var i = 1; i < lines.length; i++) { + var currentLine = lines[i].trim(); + if (currentLine === '') continue; + + var values = currentLine.split(','); + var jsonRow = {}; + + for (var j = 0; j < sanitizedHeaders.length; j++) { + var key = sanitizedHeaders[j]; + jsonRow[key] = (values[j] || '').trim(); + } + + sheetRecords.push(jsonRow); + totalRecords++; + } + + // Add the single CSV file result to the final output array + allSheetData.push({ + "SheetName": "Single_CSV_Sheet", + "Records": sheetRecords + }); + + } else { + outputs.resultmessage = 'Error: Unsupported file format. File Name: ' + attGR.file_name; + return; + } + + // 3. Set Success Outputs + // The final JSON string is now an array containing sheet objects. + outputs.jsondatastring = JSON.stringify(allSheetData); + outputs.resultmessage = 'Success: ' + totalRecords + ' records parsed across ' + allSheetData.length + ' sheets from file: ' + attGR.file_name; + + } catch (ex) { + outputs.resultmessage = 'A critical scripting exception occurred: ' + ex.getMessage(); + } + +})(inputs, outputs); + 71aa7f6647032200b4fad7527c9a719b + + + sys_hub_step_instance + 2dacab7cc3243210d9d679ec0501310f + 400 + sys_variable_value + viraj.hudlikar + 2025-10-10 14:41:54 + e5acab7cc3243210d9d679ec05013124 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + 35aa573fd7802200bdbaee5b5e610375 + f5e56d79b3101300176b051a16a8dce4 + + + + application + 2dacab7cc3243210d9d679ec0501310f + viraj.hudlikar + 2025-10-10 14:41:54 + a1acab7cc3243210d9d679ec05013124 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + attachmentSysId + 2dacab7cc3243210d9d679ec0501310f + viraj.hudlikar + 2025-10-10 14:41:54 + e1acab7cc3243210d9d679ec05013125 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_hub_step_ext_input_2dacab7cc3243210d9d679ec0501310f
+ {{action.attachment_sysid}} +
+ + script + 2dacab7cc3243210d9d679ec0501310f + viraj.hudlikar + 2025-10-10 14:41:54 + 65acab7cc3243210d9d679ec05013124 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String + false + + + + + + + + + + + + + false + false + + + + attachmentSysId + false + + + + false + + + string + + true + 8000 + 2dacab7cc3243210d9d679ec0501310f + 2dacab7cc3243210d9d679ec0501310f + sys_hub_step_instance + var__m_sys_hub_step_ext_input_2dacab7cc3243210d9d679ec0501310f + + 0 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_input + viraj.hudlikar + 2025-10-10 14:41:54 + e9acab7cc3243210d9d679ec05013113 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=aac94d33-ef73-42f3-a718-9695d163abd6 + false + + + + + + + + + + + + + false + false + + + + resultmessage + false + + + + false + + + string + + false + 8000 + 2dacab7cc3243210d9d679ec0501310f + 2dacab7cc3243210d9d679ec0501310f + sys_hub_step_instance + var__m_sys_hub_step_ext_output_2dacab7cc3243210d9d679ec0501310f + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + viraj.hudlikar + 2025-10-10 14:41:54 + 21acab7cc3243210d9d679ec05013118 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=c402e939-bede-49eb-b5bf-99cee908099c + false + + + + + + + + + + + + + false + false + + + + jsondatastring + false + + + + false + + + string + + false + 8000 + 2dacab7cc3243210d9d679ec0501310f + 2dacab7cc3243210d9d679ec0501310f + sys_hub_step_instance + var__m_sys_hub_step_ext_output_2dacab7cc3243210d9d679ec0501310f + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + viraj.hudlikar + 2025-10-10 14:41:54 + e9acab7cc3243210d9d679ec0501311b + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + jsondatastring + + + + en + var__m_sys_hub_step_ext_output_2dacab7cc3243210d9d679ec0501310f + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + 61acab7cc3243210d9d679ec0501311e + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + resultmessage + + + + en + var__m_sys_hub_step_ext_output_2dacab7cc3243210d9d679ec0501310f + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + adacab7cc3243210d9d679ec0501311a + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=09bc19ab-b8ce-4b6c-841c-b288c3a88d72 + false + + + + + + + + + + + + + false + false + + + + attachment_sysid + false + + + + false + + + string + + true + 8000 + 19acab7cc3243210d9d679ec05013104 + 19acab7cc3243210d9d679ec05013104 + sys_hub_action_type_snapshot + var__m_sys_hub_action_input_19acab7cc3243210d9d679ec05013104 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + viraj.hudlikar + 2025-10-10 14:41:54 + d1acab7cc3243210d9d679ec05013107 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,co_type_name=FDACTIONSTATUS,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=object,uiTypeLabel=Object,uiUniqueId=7947ce24-f4b3-4cde-ac86-20db6c3ebb86 + false + + + + + + + + + + + + + false + false + + + + __action_status__ + + false + + + + false + + + + string + + false + 65000 + 19acab7cc3243210d9d679ec05013104 + 19acab7cc3243210d9d679ec05013104 + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:41:54 + 65acab7cc3243210d9d679ec05013128 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=489e7feb-7b03-41d4-a3d5-df69dec341f4 + false + + + + + + + + + + + + + false + false + + + + json_data + + false + + + + false + + + + string + + false + 8000 + 19acab7cc3243210d9d679ec05013104 + 19acab7cc3243210d9d679ec05013104 + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:41:54 + 6dacab7cc3243210d9d679ec0501312c + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=af32d0ab-f671-49f2-aa8b-e07d057fccb7 + false + + + + + + + + + + + + + false + false + + + + resultmessage + + false + + + + false + + + + string + + false + 8000 + 19acab7cc3243210d9d679ec05013104 + 19acab7cc3243210d9d679ec05013104 + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:41:54 + a5acab7cc3243210d9d679ec05013136 + 0 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=e618bf6c-f5a6-4a77-8d34-ce2cccaddcf7,visible_in_ui=false + false + + + + + + + + true + + + + + false + false + + + + __dont_treat_as_error__ + + false + + + + false + + + + boolean + + false + 40 + 19acab7cc3243210d9d679ec05013104 + 19acab7cc3243210d9d679ec05013104 + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + viraj.hudlikar + 2025-10-10 14:41:54 + e9acab7cc3243210d9d679ec05013130 + 1 + + + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + false + false + false + false + false + simple + false + script + + + false + + + + + + + 19acab7cc3243210d9d679ec05013104 + viraj.hudlikar + 2025-10-10 14:41:54 + 21acab7cc3243210d9d679ec05013141 + 0 + viraj.hudlikar + 2025-10-10 14:41:54 + + + + attachment_sysid + + + + en + var__m_sys_hub_action_input_19acab7cc3243210d9d679ec05013104 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + edacab7cc3243210d9d679ec0501310a + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + + __action_status__ + + + + en + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + 21acab7cc3243210d9d679ec0501312c + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + __dont_treat_as_error__ + + + + en + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + 69acab7cc3243210d9d679ec05013135 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + json_data + + + + en + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + adacab7cc3243210d9d679ec0501312f + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + resultmessage + + + + en + var__m_sys_hub_action_output_19acab7cc3243210d9d679ec05013104 + + sys_documentation + viraj.hudlikar + 2025-10-10 14:41:54 + e5acab7cc3243210d9d679ec05013139 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + viraj.hudlikar + 2025-10-10 14:41:54 + + + + + + 556a63b8c3243210d9d679ec05013122 + 19acab7cc3243210d9d679ec05013104 + glide-zurich-07-01-2025__patch0-07-15-2025_07-23-2025_1759.zip + +