I need to set short description in SCTASK

Udit5
Tera Contributor

Hi Team,

 

I need to set short description field in SCTASK based on the variable of a catalog item.

 

If variable option chose as 'a' then short description should be read as 'need new project in a' .

if variable option chose as 'b' then short description should be read as 'need new project in b'.

 

This can be done in flow designer script so please tell me what can i write in that short description field script.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello,

Please check the below approach to set the short description:

You have to use the Get Catalog variables action as shown below:

find_real_file.png

Then on Create catalog task action you can use:

Without script

find_real_file.png

Using script:

find_real_file.png

var getVariableValue = fd_data._1__get_catalog_variables.<your_variable_name>;
return "Need new Project for " + getVariableValue;
 
if you have 2 separate variables (variable a and variable b)
if(fd_data._1__get_catalog_variables.variable_a) {
return "Need new Project for " + fd_data._1__get_catalog_variables.variable_a; 
} else if (fd_data._1__get_catalog_variables.variable_b) {
return "Need new Project for " + fd_data._1__get_catalog_variables.variable_b;
}

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

5 REPLIES 5

Sagar Pagar
Tera Patron

Hi,

Try this in catalog task scripts -

 

if(current.variables.your_variable_name == "a"){

task.short_description = "need new project in " + current.variables.your_variable_name.getDisplayValue();

}else if(current.variables.your_variable_name == "b"){

task.short_description = "need new project in " + current.variables.your_variable_name.getDisplayValue();

}

else{

task.short_description = "need new project in ";

}

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Thank you for your response Sagar.

Without scripting method worked given by Mahendra

Mahendra RC
Mega Sage

Hello,

Please check the below approach to set the short description:

You have to use the Get Catalog variables action as shown below:

find_real_file.png

Then on Create catalog task action you can use:

Without script

find_real_file.png

Using script:

find_real_file.png

var getVariableValue = fd_data._1__get_catalog_variables.<your_variable_name>;
return "Need new Project for " + getVariableValue;
 
if you have 2 separate variables (variable a and variable b)
if(fd_data._1__get_catalog_variables.variable_a) {
return "Need new Project for " + fd_data._1__get_catalog_variables.variable_a; 
} else if (fd_data._1__get_catalog_variables.variable_b) {
return "Need new Project for " + fd_data._1__get_catalog_variables.variable_b;
}

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Hey Mahendra , thank you for the quick response.
Without scripting method worked. 🙂