Need help on Service Portal widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 07:51 AM
The requirement is to create a new widget that should only be visible when users click on specific subcategories.
Could you please assist with the HTML, Server Script, and Client Script for this functionality?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 03:44 AM
As your logic is only in the server script, when a new category is changed you need to listen for that change in your widget.
You can do this in your client script by listening for "$sp.service_catalog.category.selected" which "SC Categories" broadcasts.
$rootScope.on("$sp.service_catalog.category.selected", function(event, data){
if(data.sys_id == 'your sysid')
c.view = true;
})
And then in your widget ng-if change data.view to c.view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 04:20 AM
Hi @Kieran Anson ,
could you please provide the updated script.
HTML:
<div>
<div class="alert alert-danger" ng-if="data.invalid_table" >
${Table not defined} '{{data.table_label}}'
</div>
<sp-widget ng-if="data.dataTableWidget && data.view" widget="data.dataTableWidget"></sp-widget>
</div>
Server script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 12:46 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 01:06 AM
Hello,
I provided a code snippet. Can you try to add that to your client script and debug? It will help you learn 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 01:05 PM
Hello @Pradeepa B
When you mention subcategories, I am assuming you are trying to refer sub-menu options (I could be wrong here). For example, below is a screenshot of CSM Portal where there are multiple sub-menu to Support Menu item:
When you click on any sub-menu item let's say Assets, then you can notice the URL changes to ".service-now.com/csm?id=csm_assets&table=alm_asset&view=csp_admin"
The Assets data displayed as shown below
So, you need to learn Service Portal > Menus. An example filter applied for CSM Portal header menu:
and under Related List - Menu Items you can locate "Support"
Upon Clicking Support, you can notice the page associated with it (top right) and all sub-menus shown in the related list.
You can click Assets and find the page id in the HREF/URL field (csm_assets)
Service Portal > Pages
The Page Content will give you the list of Widgets associated with the page
You need to create a Widget either by cloning an existing OOB one or from scratch and then in the Page design you need to add container (if not exists already), select the size number mentioned under container (any number under Container in the left), drag it to the right, search your widget (Top left - Filter Widget) to drag and drop from left to the right (in the container).
You can take reference from one of my recent post to create a widget here.
Hope that helps!
Hope that helps!