- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2017 05:47 PM
How does one get the sys_id of the current page that the user is viewing in the service portal?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2017 06:35 PM
Hi Scott,
My bad. I thought you were trying to retrieve sys_id from the URL.
You can try below code to get the sys_id of current page,
var page_id = $sp.getParameter('id');
var gr = new GlideRecord('sp_page');
gr.get('id',page_id);
var page_sys_id = gr.sys_id;
Hope this helps.
Do not feel shy to mark correct or helpful answer if it helps or is correct.
Best Regards,
Nitesh Asthana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:58 AM
Thank you for posting back
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 08:49 AM
If you only need it in the controller, it is already on $scope:
function($scope) {
var page_id = $scope.page.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2018 09:37 AM
Just to add to this, if you want to get the page id or other parameters when the page changes you can look for the $locationChangeSuccess event and set the current page. The $scope.page.id does not update when the page changes. This is useful when you are looking to highlight menu items or header links. The header and footer are not re-run on page change, and you have to look for a page change event.
In the Client controller:
function($scope, $location) {
var c = this;
c.current_page = $scope.page.id; //set the current page when first loaded
$scope.$on.('$locationChangeSuccess', function() {
c.current_page = $location.search().id;
});
}
Example HTML:
<ul>
<li ng-class="{'active': c.current_page == 'my_incidents'}">
<a href="?id=my_incidents'">My Incidents</a>
</li>
</ul>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2023 08:08 AM
Hello @stephend_angelo ,
I have created side menus on my service portal. when I click on the menu I want to show whatever content is present inside a specific menu beside side menus. I am very new to the service portal how can I achieve this functionality please guide me on this.
Thank you