Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Populate the catalog item Variable label and values in RITM description

Somujit1
Tera Contributor

Hi,

 

Is there a way I can define in the Flow designer, to display the variable label and filled in values on the RITM Description field for the catalog item being requested 

I created a RITM Update record action in the flow to update the Description where it gives me option to select values using data pill and also shows a script option.

 

I have written the below script which return the variable values as comma separated.

However I am not able return the variable label and display it in line break format

------------

var ritmSysId = fd_data.trigger.ritm.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var variableValue= rec.variables.getElements();
return variableValue;
---------------
Any suggestions on how to get the Variable label display values and display in sequence
1 ACCEPTED SOLUTION

@Somujit1 

Glad to know.

Yes you can but for that you need to enhance the script and check if the value is not false

something like this

var ritmSysId = fd_data.trigger.ritm.sys_id;


var ritm = new GlideRecord('sc_req_item');
ritm.get(ritmSysId);

var arr = [];
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != '' && value != '' && value != 'false'){
arr.push(label + " - " + value);
}
}
return arr.join('\n');

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

View solution in original post

10 REPLIES 10

@Somujit1 

Please mark my response as correct and close the thread.

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

Hi @Ankur Bawiskar  It is giving me below error

 

Somujit1
Tera Contributor

@Ankur Bawiskar , I have a Additional Info variable in my catalog item. Using the above script it is returning the defined variable labels and their values.

Is there a way I can modify the script to display the Additional Info variable to be displayed as 'Details - <value>' at the end of all other variable labels and their values in the RITM description field

 

Thanks in advance.

Somujit

 

@Somujit1 

so you don't want the Label - {Value} format?

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

@Ankur Bawiskar  in the catalog item i have below variables -

1. Type of Request

2. Application Name

3. Requested Date

4. Provide more details related to your request

 

In the RITM description, it needs to display as below

Type of Request - <value>

Application Name - <value>

Requested Date - <value>

Details - <value> (instead of the actual variable label name for #4)