Issue
Description
This documentation explains how to create a simple Service Portal Widget to display a single field of a record.
Procedure
- Follow the documentation to create a basic widget in the instance. https://docs.servicenow.com/csh?topicname=create-new-widget.html&version=latest
- 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/csh?topicname=c_Widgets.html&version=latest