Configurable Portal Widgets - How to pull sys_id?

Mike Sabia1
Tera Expert

1)  For the Portal Object Widget, THIS page says for the Record option, "If this field is empty, the widget displays information based on the sys_id parameter provided in the portal web page URL." but if I leave the field blank, it shows and uses the default example from the alm_asset table.  How do I get it to pull the sys_id from the URL?

2) For the Portal Data List Widget, it works great for just providing a list such as replacing the default list widget on (a clone of) the my_projects page (which comes with the 'Customer Project Management'/sn_csm_ppm plugin).  However, can this be used on a Record Page to show sub lists?  If I place it on (a clone of) the project_detail page, a) it doesn't pick up the project record and rather than showing the Contacts for that Customer Project, it instead shows all Contacts.  (As well, if I click on a Category, the URL loses the sys_id shown before I select a Category) How can I get it to filter?  THIS page doesn't give options on the query line

I've tested with Vancouver Patch 6 and Washington Patch 0 and the latest version 3.3 of the 'UI Components for Customer Portals' plugin

Thanks!!

2 ACCEPTED SOLUTIONS

You'd need to modify the widget and put it in the Server Script field, entering it in the field like that won't work.  Then from the server script pass it to the client controller or HTML template.

Something similar to the below to pass the data.  

Server Script:  
var id = $sp.getParameter('sys_id');

Client Controller:
c.id = $scope.data.id

HTML Template:
{{c.id}}

View solution in original post

ServiceNow responded:

#1 is a known bug which they are working on

#2 is an enhancement on their roadmap

Based on this, I am accepting previous suggestion

Changes made to Server Script of Portal Object widget

    //var sysId = options.record_sysid || $sp.getParameter('sys_id');
    var sysId = $sp.getParameter('sys_id');

View solution in original post

10 REPLIES 10

The Machine
Kilo Sage

I believe you can do $sp.getParameter('sys_id') or what ever you named it and that'll pull the value from the URL and then you can use it in your widget.  Similar to the form-widget

Unfortunately, that does not work.  See screenshot
portal_object.png

You'd need to modify the widget and put it in the Server Script field, entering it in the field like that won't work.  Then from the server script pass it to the client controller or HTML template.

Something similar to the below to pass the data.  

Server Script:  
var id = $sp.getParameter('sys_id');

Client Controller:
c.id = $scope.data.id

HTML Template:
{{c.id}}

Ideally, we shouldn't need to customize the widget in light of the documentation on the Record field, but yes, found where to modify the 'Portal Object' widget.  Thanks!

 

Now on to the second question.  May need to delve into the Widget code there as well.  Though I'd be interested in finding out if there's a way to configure rather than edit the Portal Data List configurable widget.