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.

Record Producer variables text added to an HTML field on an Idea record.

James Hollingto
Tera Contributor

Hi there,

 

I have created a record producer that creates an idea and I would like to pull through some of the inputs from the variables into the idea_description field but, this field is an HTML field and so the text appears without any formatting.

 

I'm looking for a solution to display the variable text, one line per variable instead of a continuous string of text.  This is the code I use and this works for the description field of other record producers like incident and change:

 

//set idea description of incident - it will overwrite values from template from "Generated Record Data" tab.
current.idea_description = 'Category: ' + producer.getDisplayValue('category') + "\n";
current.idea_description = 'Business Unit: ' + producer.getDisplayValue('business_unit') + "\n";
if (producer.getDisplayValue('more_business_unit') == 'Yes') {
current.idea_description += 'Business Unit 2: ' + producer.getDisplayValue('business_unit_2') + "\n";
current.idea_description += 'Business Unit 3: ' + producer.getDisplayValue('business_unit_3') + "\n";
current.idea_description += 'Business Unit 4: ' + producer.getDisplayValue('business_unit_4') + "\n";
} else {
current.idea_description += 'More than one Business Unit: ' + producer.getDisplayValue('more_business_unit') + "\n";
}
current.idea_description += 'Change Sponsor: ' + producer.getDisplayValue('sponsor') + "\n";
current.idea_description += 'Description of Change: \n' + producer.getDisplayValue('describe_your_change') + "\n";
current.idea_description += 'Problem resolved by Change: \n' + producer.getDisplayValue('change_resolve_problem') + "\n";
current.idea_description += 'Business Benefit: \n' + producer.getDisplayValue('change_business_benefit') + "\n";
current.idea_description += 'Change implementation impact: \n' + producer.getDisplayValue('change_impact') + "\n";
current.idea_description += 'Known risks if not implemented: \n' + producer.getDisplayValue('change_risk');

 

This how the text displays in within the idea description field:

 

JamesHollingto_0-1674639200616.png

This is how I would like it displayed:

 

JamesHollingto_1-1674639277870.png

Should I just encapsulate the javascript within div and paragraph elements?

 

Many thanks in advance for your help.

 

1 REPLY 1

robinsamberg
Tera Expert

Hi, I have the exact same question.  Record producer where the variable responses will dump into the HTML body of a KB Article, with each variable on its own line.  Can't imagine there's not a way to make this happen these days.  Thanks!