The CreatorCon Call for Content is officially open! Get started here.

New Line not being honoured in script output

spike
Mega Sage

I've got a BR to copy the cause, fix and workaround details from a Root Cause Analysis problem task to its parent problem when the task is closed.

The issue is that the first \n's that I output as part of the copy appear to be getting ignored. I've no idea why.

The code looks like this:

 

	// Add your code here
	var gr = new GlideRecord('problem');
	gr.get(current.problem);
	
	var task_start = ' \n\nNotes from Task ' + current.number + ': ' + current.short_description + ' follow:\n\n';
	var task_end = '\n\n----------\n\n';
	
	if (current.workaround != '') {
		gr.workaround += task_start + current.workaround + task_end;
	}

	if (current.cause_notes != '') {
		gr.cause_notes += task_start + current.cause_notes + task_end;
	}

	if (current.fix_notes != '') {
		gr.fix_notes += task_start + current.fix_notes + task_end;
	}
	
	gr.update();

 

 
And the output looks like this:
 

 

---------- Notes from Task PTASK0010028: Testng 10 follow:

Cause 10

---------- Notes from Task PTASK0010029: Testing 11 follow:

Cause 11

 

 

You can see where the new comment (starting 'Notes') runs straight on from the dashes, despite there being copious amounts of \n in play.

Does anyone have an ideas how I might get round this?

Thanks!

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @spike 

 

The fields you are trying to update are HTML type fields in problem table

Issue - Using the escape character "\n" in an HTML field does not insert a new line (line feed) when rendering the content.

Resolution - Use the HTML tag "<br />" instead of the newline escape character

View solution in original post

2 REPLIES 2

Manmohan K
Tera Sage

Hi @spike 

 

The fields you are trying to update are HTML type fields in problem table

Issue - Using the escape character "\n" in an HTML field does not insert a new line (line feed) when rendering the content.

Resolution - Use the HTML tag "<br />" instead of the newline escape character

I was for some reason convinced that wasn't going to work. But it has. Many thanks!