UI Builder: refresh single scores via button

ThunderDev
Tera Guru

I have several single scores on a homepage as well as a refresh button. I am wanting to refresh all of the single score components when this button is clicked. Any ideas on how to achieve this? 

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

The data visualization components have a property called Refresh requested you can use to refresh the component. The steps would be in UIB:

  1. Create a client state parameter called something like refreshRequested and set it to an empty string
  2. Bind that CSP to the Refresh requested property on all data vis and list components (single score is a data vis component) you want to refresh.
  3. Write a client script that sets the value of the refreshRequested:
    api.setState('refreshRequested', {timestamp: Date.now()})​
  4. Trigger that client script from your button.

There's an old video of me using this method to trigger a refresh on a list in the last video on this post: https://developer.servicenow.com/blog.do?p=/post/quebec-ui-builder-lists/ 

View solution in original post

8 REPLIES 8

Nothing specific, but I would just keep an eye on the performance. Real-time or regular refreshing is always going to be less performant than not.

Community Alums
Not applicable

That property is not working for me. I kept the interval as 1min. It doesnot refresh after a minute

Could you be more specific? What have you tried so far and what behavior are you seeing? Please post the code and screenshots.

Community Alums
Not applicable

saichaitanya_0-1727706348991.png

In Ui builder - I want donut report to refresh automatically for every minute.  I tried both fields "Refresh Requested  & Refresh after being away for Xmin". The report is not refreshing