The CreatorCon Call for Content is officially open! Get started here.

Record Watcher in UI Builder not refreshing data resource

estierle1
Tera Contributor

Hi All,

So I have created a custom dashboard in UI Builder to display some tiles using a repeater and card base containers. The repeater gets data from a lookup multiple records data resource configured to query the cmdb_ci_service_group table with condition set to only look at records with a specific Tag and returns the Severity field. There is a Header component and highlighted value component that are data bound to the data from this data resource. I then set a record watcher data resource to watch the cmdb_ci_service_group table with same condition set, so it is only watching the same records for changes. I have an event setup to REFRESH the Lookup data resource when it receives a message that there is a change to the record, specifically the severity value changes. After this is all setup, the refresh does not seem to work when I manually update the severity to test. I have tried to set the condition to be Severity>Changes, but Changes is not an option. Not sure how to set the condition to watch specifically the change in the Severity value. Any ideas out there?

4 REPLIES 4

rohansargar
Mega Guru
Mega Guru

Hello @estierle1,

 

Use Scoped API Proxy : 

 

Instead of calling /api/now/... directly from the sandboxed page, create a Scripted REST API (or a custom endpoint) in your instance that the page can call through a ServiceNow provided proxy (spProxy).
1) Inside the sandbox, use $http or spUtil.get to call your backend proxy.
2) The proxy makes the server-side call, so the sandbox restrictions are bypassed.
3) This way you keep sandbox enabled and postMessage continues to work.

If my response helped please mark it as correct,

BR,

Rohan

IronPotato
Mega Sage

Hi @estierle1 ,

how exactly do you refresh this lookup records? Do you have this on OOB event like Message Received on Record Watcher, or do you have client script added making sure that message that you received is actually correct? Because you could receive successful message from Record Watcher saying that you don't have ACL permissions to read for example. So just hang the client script on message received event and log that event there and see what it says.

 

Make sure that the message is what you've expected and react on that.

Hi @IronPotato ,

So I am using a record watcher data resource to look for changes to records in the cmdb_ci_service_group table. I am filtering the records to "watch" by filtering using a specific Tag. I am using an event on the record watcher of Message received and the handler is the REFRESH the Look up Service data resource. See images attached.

That's what I'm saying you don't know whether message was received or if it was successful. Create simple client script, name it "logEvent" and inside that client script add this line of code:

 

console.log("event from record watcher", event);

 

Then add this client script on your Record Watcher Data Resource on 3 events:

"Message Received"

"Subscription Succeeded"

"Subscription Failed"

Save your changes

 

Refresh your browser where you have your page and open browser console. Now make the change to one of the records matching your filter condition and watch which event was triggered.

 

You should be able to determine whether it was successful, whether it failed and if success what message it gets you back. From that point you can start debug and react.