How can you output new line from Close Notes on Service Portal

JC S_
Mega Guru

We are trying to show the Close Notes of an incident ticket on the Service Portal and on our widget we can only get the plain text version of the contents of Close Notes from incident table. Is there a way to get the contents of that field with the paragraph lines intact?

HTML

<p>{{data.CloseNotes}}</p>

Server script

data.CloseNotes = $sp.getFields(gr, 'close_notes');
if(data.CloseNotes != '') {  

            data.CloseNotes = data.CloseNotes[0].display_value;  

}

 

03/27/2018: I tried the solution by shashank13 but it did not show any value at all now:

HTML

<div ng-if="field.value && (field.type != 'decimal' || field.type == 'decimal' && field.value != 0)" class="m-b break-word" ng-repeat="field in data.CloseNotes">
          <label class="m-n">{{field.label}}</label>
          <div ng-switch-default ng-bind-html="field.display_value">{{field.display_value}}</div>
</div>

Server script

data.CloseNotes = $sp.getFields(gr, 'close_notes');
1 ACCEPTED SOLUTION

dpalmer
Kilo Guru

Hello JC;

Would it be possible to provide a pic of what the text is displaying as and what you want it to display as? Im not sure if your simply trying to preserve the line breaks in the text, which in that case, you may want to wrap <pre>{{data.CloseNotes}</pre> in pre tags like so, or you can utilize the css white-space property with the following name value pair: white-space:pre-wrap. So you could add a class to your p tag like <p class="wrapped">{{data.CloseNotes}</p>, and use the following css rule set:

.wrapped{

white-space:pre-wrap;

}

Im not sure if this is what you are referring to.

View solution in original post

8 REPLIES 8

JC S_
Mega Guru

Any ideas on this?

Shashank Vashi1
Mega Guru
Mega Guru

Please use the below mentioned code in HTML. This code will bind the display value of the field of your table in your widget.

<div ng-switch-default ng-bind-html="field.display_value" ng-if="field.label != 'Short description'">{{field.display_value}}</div>

Hi, I tried this but the values displayed as empty, only the label showed up. I have updated my code above for reference.

Thanks Shashank, This worked for me.