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

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/ 

Brad,

 

Thanks for the fast reply, however I do not see the refresh requested property on my single score component, where can I find this property so that I can bind the CSP?

ThunderDev_0-1724419499998.png

 

It looks like that property may have been added in Washington. Which release are you on?

Brad,

 

Thanks for the reply! Currently on Vancouver but will be upgrading to Washington soon. Until then I will probably use the real time update to keep those scores up to date in real time. Are you aware of any performance issues with using that for multiple scores?