
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 10:03 AM
Does anyone know how to make the Description field in the Ticket Fields widget into HTML? I've seen some posts to use the $sce and bind HTML but not sure how to incorporate that into the widget code.
Thanks,
Aryanos
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2018 12:56 AM
Okay got your point. Its not like the widget is not rendering the description as HTML. Actually in description you are getting \n as new line character while you need <br /> for html. Try to replace all \n with <br /> and it should work fine. Simply replace below line in code.
data.description = gr.description.getHTMLValue().replace(/\n/g,'<br />'); ;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 06:49 AM
Hi,
I'm sure you saw this post, since you're mentioning the components: https://community.servicenow.com/community?id=community_question&sys_id=876d4be9db9cdbc01dcaf3231f96...
But the first part of her correct answer goes in the HTML portion of the widget (after you clone it of course because you can't edit it default) and then the second part, she says to place in the client script portion. Just add to it.
Looks to be it.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2018 09:28 PM
Hi Allen,
I'm still having issues getting it to work. Here's what I have so far:
HTML template
<div class="m-b break-word" ng-repeat="field2 in data.fields2" ng-if="field2.value && (field2.type != 'decimal' || field2.type == 'decimal' && field2.value != 0)">
<label class="m-n bold">{{field2.label}}</label>
<div ng-bind-html="field2.display_value"></div>
</div>
Client Script
function ($scope, spUtil){
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
});
}
function ($scope, $sce){
var c = this;
//display html field
$scope.data.fields2 = $sce.trustAsHtml($scope.data.fields2);
}
The first function is there by default and I added the second one in. I think this might be the issue as I'm not sure if it's calling the second function and I've tried to combine the two (add $sce as parameter and put the code in the first function) but it blanks out the widget. The variable data.fields2 is from the Server script that has the Short Description and Description fields in it. Do you know what I may be doing wrong?
Thanks,
Aryanos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2018 10:24 PM
There's a glideRecord method to get HTML out of html fields. Try to use that in server code and use ng-bind-html in html template.
Server Code:
data.fields2 = gr.<htmlFiledName>.getHTMLValue();
Client Controller:
function ($scope, spUtil){
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2018 10:56 PM
Hi Gurpreet,
I tried the following: data.field2 = gr.field2.getHTMLValue(); but that didn't work. I don't think I have to specify the description field. I've included the entire Server script as that might help understand the setup better.
Server script
(function(){
data.pickupMsg = gs.getMessage(options.pickup_msg);
var gr = $sp.getRecord();
data.canRead = gr.canRead();
if (!data.canRead)
return;
var agent = "";
var standardFields = 'number,state,priority,caller_id,sys_created_on';
var additionalFields = 'assignment_group,short_description,description';
var a = $sp.getField(gr, 'assigned_to');
if (a != null)
agent = a.display_value;
var fields = $sp.getFields(gr, standardFields);
if (gr.getValue("sys_mod_count") > 0)
fields.push($sp.getField(gr, 'sys_updated_on'));
var fields2 = $sp.getFields(gr, additionalFields);
if (gr.getValue('price') > 0)
fields.push($sp.getField(gr, 'price'));
if (gr.getValue('recurring_price') > 0) {
var rp = $sp.getField(gr, 'recurring_price');
if (gr.isValidField("recurring_price"))
rp.display_value = rp.display_value + " " + gr.getDisplayValue("recurring_frequency");
fields.push(rp);
}
data.tableLabel = gr.getLabel();
data.fields = fields;
data.fields2 = fields2;
data.variables = $sp.getVariablesArray();
data.agent = agent;
data.agentPossible = gr.isValidField("assigned_to");
data.table = gr.getTableName();
data.sys_id = gr.getUniqueValue();
})()