Populate Catalog task description based on Variable choices

Cat
Mega Guru

Hi All,

 

I'm hoping someone can help me with this.

 

I have a requirement to be able to populate the description of the request item/catalog task based on what was chosen in a variable.

For example, I have a variable called Team which has 10 different options. If Team 1 is selected, I need the description to say something like "Please assign the following roles: Role1, Role2, Role3". If Team 2 is selected, I need the description to say "Please assign the following roles: Role3, Role4, Role5" and so on.

 

What would be the best way for me to do this?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Cat 

you can use Advanced Script in Catalog Task Activity of workflow and set the Description of SC Task

AnkurBawiskar_0-1761307924872.png

 

var val = current.variables.variableName; // give variable name here

// use the correct choice values to compare
if (val == 'Team1')
    task.description = 'Please assign the following roles: Role1, Role2, Role3';
else if (val == 'Team2')
    task.description = 'Please assign the following roles: Role3, Role4, Role5';
	// and so on

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

nitishkumarkami
Tera Contributor

@Cat , you can achieve this by creating a decision table and using it within your flow. The decision table can map each Team option to its corresponding description.

Then, in your flow, use the decision table output to update the RITM and Catalog Task descriptions accordingly.

Decision Tables in ServiceNow 

D11 - Decision Builder & Decision Table - Flow Designer In this video, I'll show decision table and use of this decision table. How can get value dynamically & with new decision builder look. Flow is a powerful design tool that can help you organise and simplify your workings within Servicenow. In

Thank you. The current form uses the Workflow Editor - is there a way to use the decision table with that?

nitishkumarkami
Tera Contributor

@Cat , No decision table can't be used in workflow. try adding Run Script activity in your workflow and write a script like below

// Get the current RITM record
var ritm = current; // In a workflow, 'current' refers to the sc_req_item record

// Get the selected team variable (replace 'team' with your actual variable name)
var team = ritm.variables.team;

// Define the role descriptions for each team
var descriptions = {
"Team 1": "Please assign the following roles: Role1, Role2, Role3",
"Team 2": "Please assign the following roles: Role3, Role4, Role5",
"Team 3": "Please assign the following roles: Role2, Role5, Role6",
"Team 4": "Please assign the following roles: Role7, Role8, Role9"
// Add more mappings as needed
};

// Get the description based on selected team
var desc = descriptions[team] || "Please assign the appropriate roles as per the team selection.";

// Update the RITM description
ritm.description = desc;
ritm.update();

// Update all related Catalog Tasks
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', ritm.sys_id);
sctask.query();
while (sctask.next()) {
sctask.description = desc;
sctask.update();
}

Ankur Bawiskar
Tera Patron
Tera Patron

@Cat 

you can use Advanced Script in Catalog Task Activity of workflow and set the Description of SC Task

AnkurBawiskar_0-1761307924872.png

 

var val = current.variables.variableName; // give variable name here

// use the correct choice values to compare
if (val == 'Team1')
    task.description = 'Please assign the following roles: Role1, Role2, Role3';
else if (val == 'Team2')
    task.description = 'Please assign the following roles: Role3, Role4, Role5';
	// and so on

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader