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.

Adding Line breaks in Business Rule for Knowledge Article

litchick10
Tera Guru

We are in New York and I am trying to add line breaks to a string field.  I can get the values to populate but not the line breaks.  I tried following this post from 5 years ago on Line Breaks in Business Rules but it does not work. Here is my code

(function executeRule(current, previous /*null when async*/) {

	(function executeRule(current, previous /*null when async*/) {

	var cin = current.u_ciname.getDisplayValue();
	var civ = current.u_civersion.getDisplayValue();
	var civv = current.u_civendor.getDisplayValue();
	var cio = current.u_ciowner.getDisplayValue();
	var ciiao = current.u_ci_itappowner.getDisplayValue();
	var lnbrk = "\n";	
	
	/*if(civ != ""){*/
		var civd = "Version: " + civ + "\n";
	/*}*/
	/*if(civv != ""){*/
		var civvd = "Vendor: " + civv + "\n";
	/*}*/
	/*if(cio != ""){*/
		var ciod = "Owner: " + cio + "\n";
	/*}*/
	/*if(ciiao != ""){*/
		var ciiaod = "IT Application Owner: " + ciiao + "\n";
	/*}*/

	current.u_kb_ci_name.setValue(cin+civd + civvd+ ciod+ ciiaod);
	
})(current, previous);

This code results in this without line breaks

find_real_file.png

1 ACCEPTED SOLUTION

SanjivMeher
Mega Patron
Mega Patron

Did you try <br> instead of \n


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

2 REPLIES 2

SanjivMeher
Mega Patron
Mega Patron

Did you try <br> instead of \n


Please mark this response as correct or helpful if it assisted you with your question.

Just tried, worked!!