Service portal - widgets to display the content of the link

Jesi Perinbaraj
Kilo Contributor

I need to create a Service Portal page, which will have two widgets, one with a couple of links and the other widget needs to display the page according to the link clicked on the first widget.

The links would be direct service now URL. I am sure there must be a target function where we can mention the target widget / class / div. I want something similar to the Service Catalog SP page. Please suggest.

Thanks in advance.

1 ACCEPTED SOLUTION

Jessie,



I think I see what you are trying to do:


Based on the screenshot below if you look at the yellow highlighted sections. If I hover over the "Can We Help You?" link you can see at the bottom of the screenshot that the link points to the same exact page it's on but the sys_id in the url is pointing to the "Can We Help You?" category. But the current category is the "Hardware" category highlighted in red. And you can see the correlating url set in the address bar with the "Hardware" category sys_id.


hardware.png




If I click on the "Can We Help You?" link then it will set the url in the address bar to the same exact page but changing the sys_id to the "Can We Help You?" category sys_id. See screenshot below. This will change the items to display the "Can We Help You?" category items.


can_we_help_you.png




The sys_id set in the url in the address bar is now taken in the server script. If you follow the script you'll see that sys_id is used to get the items from the category that correlates to that sys_id.


sc_category_page_widget.png



In conclusion this page is set up with two widgets to communicate with each other by using a link to point to itself but supply a different value for the sys_id parameter. When a new parameter is supplied new items will display based on the new value accepted by the other widget.



I hope this helps.


P.S. Aside from the "How to Communicate Between Two Widgets" way another technique is to use the URL and place parameters on it.


View solution in original post

7 REPLIES 7

Hi Jessie,


    Curious as to see other people's answer to this question. My understanding is that is passing those parameters through the URL. However since we are developing an application within an existing application it can pass those parameters through the backend. You can see those "$sp" methods are performing some of the "magic", here is a good resource of service portal methods that are available to you: GitHub - Service-Portal Documentation. Hope this helps.



Best,
    Philip E.


Jessie,



Simply putting parameters on the url string will make them accessible to a widget. As I mentioned in my previous post the "sys_id=" part of the url is an example parameter where in the script part of the widget you can use $sp.getParameter('name of parameter') to grab the value assigned to that parameter.



However, I'm not understanding 100% what you're trying to do. Your post reads like the two widgets are on the same page where using a URL link to click on wouldn't be the best option to do. Also it sounds like you want to show a ServiceNow page that is not a portal page within a widget. If that is true are you thinking of using an iframe or have you already worked out a widget that will rendered a specific "ServiceNow page".



Maybe a more clear example with some screenshots or at least some of your script that you have already made will help give a better understanding of what it is you're trying to accomplish.


Jessie,



I think I see what you are trying to do:


Based on the screenshot below if you look at the yellow highlighted sections. If I hover over the "Can We Help You?" link you can see at the bottom of the screenshot that the link points to the same exact page it's on but the sys_id in the url is pointing to the "Can We Help You?" category. But the current category is the "Hardware" category highlighted in red. And you can see the correlating url set in the address bar with the "Hardware" category sys_id.


hardware.png




If I click on the "Can We Help You?" link then it will set the url in the address bar to the same exact page but changing the sys_id to the "Can We Help You?" category sys_id. See screenshot below. This will change the items to display the "Can We Help You?" category items.


can_we_help_you.png




The sys_id set in the url in the address bar is now taken in the server script. If you follow the script you'll see that sys_id is used to get the items from the category that correlates to that sys_id.


sc_category_page_widget.png



In conclusion this page is set up with two widgets to communicate with each other by using a link to point to itself but supply a different value for the sys_id parameter. When a new parameter is supplied new items will display based on the new value accepted by the other widget.



I hope this helps.


P.S. Aside from the "How to Communicate Between Two Widgets" way another technique is to use the URL and place parameters on it.