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.

Pass Record Producer variables questions and answers to Description field

Dazler
Mega Sage

Hi,

I have created a Record Producer form for our incident table.  They don't want the variable editor on the Incident form, so instead to retrieve the questions and answers I suggested we pass them into the description field.

I found this script and it sort of works.

var populatedList = '';
 
for (v in current.variables) { 
var question = current.variables[v].getQuestion(); 

if(question.getLabel() != '');
{
populatedList += question.getLabel() + ":" + question.getDisplayValue() + '\n';
}

}

 

But it is retrieving all the variables questions and answers, including those that are not answered and null fields.

find_real_file.png

Does anyone have a better script for this?

Any help would be appreciated.

8 REPLIES 8

Hi @sachin.namjoshi

This script works, but with the some of my values are reference fields and are display at the sys_id.

find_real_file.png

 

Am I able to retrieve the display name or am I going to have to query the table to retrieve the display name of that sys_id?

If it's a referenced field to sys_user table, you just have to change one line in the code

 

var ciGR = new GlideRecord('sys_user');

 

Regards,

Sachin

Anoja
Mega Sage

Hi,

current.description = 'Additional details : ' + producer.description +

'\n User ID: ' + producer.user_name.getDisplayValue() +

'\n Contact Info : ' + producer.u_call_back_number.getDisplayValue();

You can try this based on your requirement.

Thanks,

Anoja

Thanks @Chekuri Anoja this was helpful. I just tweaked it slightly as per my fields.