Get the display value in service portal widget for reference fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 05:52 AM
Once request item get created, in service portal widget customer view couple of variable values showing in sys id format instead of actual value (display values).This is happen after Rome upgrade. Here i am giving the widget code.
HTML:
<div ng-if="data.canRead" class="panel b">
<div class="panel-heading bg-primary">
<div ng-init="spSearch.targetRequests()">
<sp-c-link target="form" table="data.table" id="data.sys_id"/>
</div>
<span ng-if="data.agent" >
${Agent working on this {{data.tableLabel}}}:
<div>{{data.agent}}</div>
</span>
<span ng-if="!data.agent && data.agentPossible" >${Your request has been submitted}</span>
<span ng-if="!data.agentPossible">${{{data.tableLabel}} record details}</span>
</div>
<div class="panel-body">
<div ng-if="data.fields.length > 0">
<div class="row">
<div class="col-md-6 col-sm-12 col-xs-6 m-b break-word" ng-repeat="field in data.fields"
ng-if="field.value && (field.type != 'decimal' || field.type == 'decimal' && field.value != 0)" >
<label class="m-n">{{field.label}}</label>
<span ng-switch="field.type">
<div ng-switch-when="glide_date_time" title="{{field.display_value}}">
<sn-time-ago timestamp="::field.value" />
</div>
<div ng-switch-default >{{field.display_value}}</div>
</span>
</div>
</div>
</div>
<div ng-if="data.variables.length > 0" ng-init="variable_toggle=true">
<h4 ng-click="variable_toggle = !variable_toggle" style="cursor: pointer;">
<span style="font-size: 12px;" class="glyphicon"
ng-class="{'glyphicon-chevron-down': !variable_toggle, 'glyphicon-chevron-up': variable_toggle}"></span>
${Options}
</h4>
<div ng-if="variable_toggle">
<hr>
<div class="m-b break-word" ng-repeat="variable in data.variables">
<label class="m-n">{{variable.label}}</label>
<div>{{variable.display_value}}</div>
</div>
</div>
</div>
</div>
<div ng-if="data.agentPossible && !data.agent && options.pickup_msg" class="panel-footer">
<div id="ticket_fields_footer" class="text-center text-muted" style="font-style: italic;" ng-bind-html="data.pickupMsg">
</div>
</div>
</div>
Client Code:
function ($scope, spUtil) {
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
})
}
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 a = $sp.getField(gr, 'assigned_to');
if (a != null)
agent = a.display_value;
var fields = $sp.getFields(gr, 'number,state,sys_created_on,stage');
if (gr.getValue("sys_mod_count") > 0)
fields.push($sp.getField(gr, 'sys_updated_on'));
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.variables = $sp.getVariablesArray();
data.agent = agent;
data.agentPossible = gr.isValidField("assigned_to");
data.table = gr.getTableName();
data.sys_id = gr.getUniqueValue();
})()
form the above widget script where we need the update to fix the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 06:14 AM
Hi,
are you using OOB widget or created new one and using that?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 06:16 AM
Hi,
are you sure those business service and service offering variable has display value populated in it?
How does it look on RITM form?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 06:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 06:54 AM
Hi,
so the value itself is showing as sys id for business service.
so that's the issue for that variable.
Now did you check for Service offering variable?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader