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 

yes that's possible

just use if statement and when that variable is being iterated replace the label

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