
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 05:34 PM - edited 05-10-2024 05:37 PM
I am building a portal where the user needs to select an account (customer_account) via an sn-record-picker. When an account is selected, I am setting a user session variable using putClientData and setting a user preference using savePreference.
All of this is working great and I've confirmed that the session and preference are getting updated. However, there are several other widgets on the page which source data from the selected account that need to be refreshed when a different account is selected. This is easy enough when the user goes to a new page, but how do I tell widgets on the current page to refresh?
It seems like the ideal solution would be to add a watcher to the widgets' client scripts (akin to spUtil.recordWatch), but there really isn't a record to watch (unless I can get it to catch the new sys_user_preference entry).
The only other option I can think of is to wait for the server update to finish on my account selector widget, and somehow trigger a page refresh. But I can't find a good way to do that on the server side.
For what it's worth, the account picker widget lives in the portal header.
Any thoughts?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 06:47 PM
Hi @John Tomko,
Are these widgets (the ones that need to be refreshed) OOB or customized?
If the latter, you should be able to use events in the widgets - https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_serviceportal_utah_se...
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 06:06 PM
For now, I am handling it by reloading the page from the client script after the server updates, but that feels kinda cheesy. I don't like making the page blink...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 06:47 PM
Hi @John Tomko,
Are these widgets (the ones that need to be refreshed) OOB or customized?
If the latter, you should be able to use events in the widgets - https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_serviceportal_utah_se...
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:47 AM
Fantastic James! Sorry it took so long to acknowledge, but I'd already decided to live with my page refresh - right up to the point where I needed to do something similar and really didn't want to refresh.