- 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-04-2018 12:22 AM
Hi Aryanos,
Try below code
Server Code:
(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'; 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')); data.description = gr.description.getHTMLValue() ; 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(); })()
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>
<div class="m-b break-word" ng-if="data.description"> <label class="m-n bold">${Description}</label> <div ng-bind-html="data.description"></div> </div>
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-04-2018 09:33 AM
Hi Gurpreet,
Thanks for the suggestion. I revised the code and it still isn't working. Any other suggestions?
Thanks,
Aryanos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 10:08 PM
Can you please share the screenshot of the widget. how it looks like. From which table you are fetching the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 10:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 10:56 PM
Okay... So Seems like it's rendering HTML property. if you use ng-bind instead of ng-bind-html then description will be rendered with html tags like <b> This is simple description </b>. But here in your case there is no html tag exposed. Can you please explain the issue in detail?