- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
We currently have a catalog item that raises a request and creates a single SC Task for one user. We’re looking to enhance this same catalog item by adding an option that allows the creation of multiple SC Tasks under a single RITM.
The idea is to upload an Excel file as part of the request, where each row in the Excel should result in a separate SC Task. The values from each row should also be used to populate the catalog variables for the corresponding SC Task or on the description field on the SC Task.
Has anyone implemented a similar solution?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
To achieve this, the most effective and up-to-date approach is to use Flow Designer along with a Custom Script Action.
Probable Steps:
1. Attachment added in catalog form and submitted
2.Set the flow to trigger when the Catalog Item record is created
3. Create a custom action in Flow Designer with below given code
4.Loop through rows
5.Create Catalog Task
6.Map fields dynamically to RITM variables
var attGr = new GlideRecord('sys_attachment'); attGr.addQuery('table_sys_id', inputs.ritm_sys_id); // The RITM sys_idattGr.orderByDesc('sys_created_on'); attGr.query(); if (attGr.next()) { var parser = new sn_impex.GlideExcelParser(); var attachmentStream = new GlideSysAttachment().getContentStream(attGr.sys_id); parser.parse(attachmentStream); while (parser.next()) { var row = parser.getRow(); // Example: Column 'Field1' and 'Field2' from Excel var tskField1 = row['Field1']; var tskField1 = row['Field2']; var taskGr = new GlideRecord('sc_task'); taskGr.initialize(); taskGr.request_item = inputs.ritm_sys_id; taskGr.short_description = "Task for " + tskField1; taskGr.description = "Details from Excel: " + tskField2; taskGr.insert(); } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
To achieve this, the most effective and up-to-date approach is to use Flow Designer along with a Custom Script Action.
Probable Steps:
1. Attachment added in catalog form and submitted
2.Set the flow to trigger when the Catalog Item record is created
3. Create a custom action in Flow Designer with below given code
4.Loop through rows
5.Create Catalog Task
6.Map fields dynamically to RITM variables
var attGr = new GlideRecord('sys_attachment'); attGr.addQuery('table_sys_id', inputs.ritm_sys_id); // The RITM sys_idattGr.orderByDesc('sys_created_on'); attGr.query(); if (attGr.next()) { var parser = new sn_impex.GlideExcelParser(); var attachmentStream = new GlideSysAttachment().getContentStream(attGr.sys_id); parser.parse(attachmentStream); while (parser.next()) { var row = parser.getRow(); // Example: Column 'Field1' and 'Field2' from Excel var tskField1 = row['Field1']; var tskField1 = row['Field2']; var taskGr = new GlideRecord('sc_task'); taskGr.initialize(); taskGr.request_item = inputs.ritm_sys_id; taskGr.short_description = "Task for " + tskField1; taskGr.description = "Details from Excel: " + tskField2; taskGr.insert(); } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The number of catalog tasks should be as per business requirement and process.
Why you are determining this based on Excel file which user will add? Why end user will decide how many SC Tasks should be there?
Example: if the user raises a laptop request then customer will have a defined process on how many SC Tasks are required. Why end user will say ?
User can add Excel with 100 rows so will you create 100 SC Tasks under that RITM?
Not a recommended idea.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
