to Change the OOB Behaviour of Service Portal For list view of Record

ABC6
Tera Contributor

i want to change the OOB behavior. I want to customize it such that, I will see this as in native view where the CI field opens the CI  record and the User field will field opens the user records.

how can we achieve it 
i have found if i can change the Data Table from URL Definition widget but i have no idea where to change, please guide me for the same

4 REPLIES 4

Satish Rana1
Tera Contributor

Go to Service Portal > Widgets
Search for "Data Table from URL Definition" this is a read-only OOB widget, so you need to clone it.
Modify the Link Behavior you need to edit the Server Script and HTML Template to enable links to native views.
Update the link logic. Now go to your cloned widget and go to "HTML Template" tab. Locate the correct ng loop where each item is displayed and replace the values.

it is cloned but i have no idea where i need to change for the same, please guide me

Community Alums
Not applicable

Step 1: Find and edit the widget

  1. Navigate to Service Portal → Widgets.

  2. Search for Data Table from URL Definition.

  3. Clone this widget first (recommended, so you don’t lose the OOB behavior).

  4. Open your cloned widget to customize.


Step 2: Change the link behavior

Inside the widget, you’ll see server script and client script.
The key part is usually in the template or client script that builds the link for each cell.

By default, it builds a URL like:

 

/sp?id=form&table=cmdb_ci&sys_id=...

 

You can change it to open the native view by making the link:

https://INSTANCE.service-now.com/cmdb_ci.do?sys_id=...

 

But instead of hardcoding INSTANCE, use:

var instanceUrl = $window.location.origin.replace('/sp', '');

 

So your click action could look like:

window.open(instanceUrl + '/' + tableName + '.do?sys_id=' + sysId, '_blank');

 

 

I have changed it but seems due to hardcode it is not working as expected i want it dynamically please guide me with this below client code where i need to change

function callDataClick(e, parms) {                                        
            var oid = $location.search().id;
            var p = $scope.data.page_id || 'form';
            console.log("MoonTest"+JSON.stringify(parms));
            var s = {id: p, table: 'cmdb_ci_business_app', sys_id: parms.record.ci.value, view: $scope.data.view};
            if (oid == p) {
                s.spa = 1;
                var t = $location.search();
                s = angular.extend(t, s);
                $rootScope.$broadcast('$sp.list.click', s);
            }

            var newURL = $location.search(s);
            spAriaFocusManager.navigateToLink(newURL.url());                                        
    }