Notifications

18 views

Issue

Description

This documentation explains how to create a simple Service Portal Widget to display a single field of a record.

Procedure

  1. Follow the documentation to create a basic widget in the instance. https://docs.servicenow.com/bundle/london-servicenow-platform/page/build/service-portal/task/create-new-widget.html
  2. Say you want to display Description Field of the record in the widget. You modify the HTML template as follows.

<div>
<div ng-if="data.hasDesc" class="panel b">
<div class="panel-heading">
<h4 class="panel-title">Description</h4>
</div>

<div class="panel-body">
{{data.desc}}
</div>
</div>
</div>

The Server Script can be modified as follows.

(function() {
var gr = $sp.getRecord();
data.desc = gr.getValue('description');
data.hasDesc = false;
if (!gs.nil(data.desc)) {
data.hasDesc = true;
console.log('desc: ' + data.desc);
}
})()

Applicable Versions

All available versions

Additional Information

https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/build/service-portal/concept/c_WidgetCreation.html

Article Information

Last Updated:2019-08-02 20:41:32
Published:2019-05-30