How do I prevent change approvals from appearing in the Service Portal view?

Mark Phillips1
Tera Contributor

Since our CAB approves change requests at their CAB meeting and we do not want any of these changes approved until then, we would like to remove all of the CHG approvals from appearing in the Service Portal view.  Sometimes we may have 30 or more changes which hinder upper management from seeing other items that need approval.

I am a low code system admin and would like to see if there is a way to do this.  I am relatively new to ServiceNow (been using it for 6 months) but am learning a lot.  Many of the people in this forum have been very helpful with that too so thank you.  I do know I have to modify the approval widget in the Service Portal but am still learning how to code in ServiceNow.  Any help would be appreciated!

2 REPLIES 2

jacob_benker
Tera Expert

You should start by cloning the 'Approvals' widget and giving it the new widget a slightly different name.

in my personal dev instance I just called it My Approvals. However, you may want to call it 'Non-Change Approvals' or 'Request Approvals'.

After you have your own version of the widget look in the 'Client Script' area.

Find the line that looks like this:

spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^approverIN" + $scope.data.myApprovals.toString());

You'll need to update the search criteria portion of this statement. "state=requested^..."

You can update it to look like this:

spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sysapproval.sys_class_name!=change_request^approverIN" + $scope.data.myApprovals.toString());

That will show all approval records except those associated with Change Requests.

You can modify it to more specific if you like. I got that by opening all approvals in a list view and putting on a filter to exclude Change request. I think right-clicked on the filter and clicked 'Copy query' to get the syntax.

Once your new widget is ready, you will want to pull the baseline 'Approvals' widget off your page(s) and replace it with your new widget.

lekskr
Kilo Expert

Thank you to all for posting this question and the solution, it is what I needed.