- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 12:15 AM - edited 06-03-2024 12:26 AM
Hello everyone,
I'm trying to add custom fields to the User Profile widget in Service Portal, i've cloned the widget and modified it to separate the fields into multiple sections, by replicating the same method used originally by ServiceNow to query the fields from the Service Portal view on the sys_user table form.
Below are the sections i replicated:
HTML:
<div class="row">
<div ng-class="{'col-md-6': teamExists(), 'col-md-12': !teamExists()}" class="col-sm-12 col-xs-12">
<div class="panel panel-default b" ng-if="getSysUserModelFieldsCO().length > 0">
<div class="panel-heading">
<h2 class="panel-title">
<i class="fa fa-question-circle m-r-sm"></i>${Coaching Preferences}
</h2>
</div>
<div class="body padder-xs">
<div class="list-group">
<div ng-repeat="fieldModelCO in sysUserModelFieldsCO">
<div class="list-group-item">
<div>
<sp-editable-field block="true" table="{{data.table}}" editable-by-user="data.isLoggedInUsersProfile" table-id="data.sysUserID" field-model="fieldModelCO"></sp-editable-field>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Server Script:
// This section is shared between all sections
data.isLoggedInUsersProfile = loggedInSysUserID.equals(data.sysUserID);
var sysUserForm = $sp.getForm(data.table, data.sysUserID);
data.sysUserView = sysUserForm._view;
data.sysUserModel = sysUserForm._fields;
//End of shared section
data.sysUserModelListCO = [];
for (var co = 19; co < data.sysUserView.length; co++) {
data.sysUserModelListCO.push(data.sysUserModel[data.sysUserView[co].name]);
}
Client Controller:
$scope.getSysUserModelFieldsCO = function() {
if ($scope.data.userExists) {
return $scope.data.sysUserModelListCO
.filter(function(field) {
return $scope.displayField("sys_user", field.name);
});
}
return [];
}
$scope.sysUserModelFieldsCO = $scope.getSysUserModelFieldsCO();
Everything seems to be working fine, the sections are separated and the fields are showing, however, it is only showing string fields, as shown in the below screenshots from the Form Designer, Platform and Service Portal:
Form Designer
Platform
ServicePortal
I couldn't figure out why the rest of the fields are not showing on the Service Portal when they're showing on the Service Portal view on the platform, also, the Year Completed fields are supposed to show only when their respective training is checked (as shown in the Platform screenshot), but they're showing on the Service Portal nonetheless.
I have checked that those fields are not on the fieldExcludes in the Client Controller.
Any help would be greatly appreciated.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 10:59 PM
I managed to resolve this by commenting this line in the client controller of the User Profile Widget
if (models[tableName][field] && models[tableName][field].type === "boolean") return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 10:59 PM
I managed to resolve this by commenting this line in the client controller of the User Profile Widget
if (models[tableName][field] && models[tableName][field].type === "boolean") return false;