Flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2024 01:58 AM
i have variable with type multiline text in my catalog item,so when we select department,role,location it(variable with multiline text) will be auto populated with some roles.using flow designer i want to create service catalog task for each role.How it can be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2024 07:10 AM
you need to have script to parse the multi-line text and then create the catalog task
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2024 07:27 AM
Hi @HARSHA GOWDA R ,
Create a custom action where you will pass input as multiline text and output as array with roles from the multiline text.After getting the output use 'for each ' in flow designer .So for each role from the output of action a catalog task will be created.
Please mark my answer correct/helpful if it resolved your query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2024 07:39 AM
Hi @HARSHA GOWDA R ,
Configure the flow to extract the roles from the multiline text variable and iterate through each role. For each role, create a service catalog task dynamically within the flow. Use appropriate actions and conditions to handle the creation of tasks based on the roles extracted from the multiline text variable.
You can try following the sample code which can be placed in the script action:
// Get the value of the multiline text variable containing roles
var rolesText = current.variables.multiline_text_variable; // Replace "multiline_text_variable" with the actual variable name
// Split the roles by line break
var rolesArray = rolesText.split("\n");
// Create an array to store the roles
var roles = [];
// Iterate through each role and trim any extra spaces
for (var i = 0; i < rolesArray.length; i++) {
var role = rolesArray[i].trim();
if (role !== "") { // Check if the role is not empty
roles.push(role);
}
}
// Save the roles array to flow variables
flow.variables.roles = roles;
If you found this helpful, a 'like' is the secret handshake of appreciation!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2024 10:23 PM
I have tried custom action which is multiline text convert to array and script action are not working as per my requirement. let me explain my exact requirement,I have a multiline text variable name is Role and Department Based Access and have a list collector which is another variable name is Additional Access. Role and Department Based Access will be auto populated with some roles which is read only type and roles will be auto populated based on Role and Department. and Additional Access will be selected by requester. so both variables have some roles, my requirement is using flow designer i want to create service catalog task for each roles from both variables.