Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Need help with record watch on single record

robhaas
Tera Contributor

I am attempting to use the spUtil recordWatch on a widget that looks at a referenced record of the open record. On my service portal page, I looked over the Real Time To Do App using Service Portal & Record Watchers - ServicePortal.io - Service Portal, CMS,...   video in attempt to replicate. I am not using the first portion as I am not adding any items to a table. I am simply looking at a record and need to see when it changes.

The widget that shows the data pulls a referenced record and is set a gr with different data variables set to their corresponding field on the record. As for my recordWatch portion in the client controller, I have :

function ($scope, spUtil,) {

      var c = this;

      spUtil.recordWatch($scope, "x_access_task", "sys_id=" + data.sys_id, function(name, data) {  

      spUtil.update($scope);

})

When the record is updated, whether that be the state, description, or any other field, nothing changes live. I'm sure I am probably over thinking this, but does anyone have any thoughts as to why it doesn't update?

8 REPLIES 8

Hmmm. Interesting.


I wonder if you're watching the wrong table? I re-read your original post and notice the you stated that you're watching   a referenced record of an open record. Have you tried watching the table of the open record instead of the referenced record?


Just tried that as well... I can see all of the changes happening in the console, but none on the darn widget


lakhrissihasna
Tera Contributor

I don't know if there is a better solution, but I found the same issue and a workaround that worked for me is to put a filter on other fields than the sys_id, then in the record watcher add a condition on the sys_id. Something like this :

var c = this;

spUtil.recordWatch($scope, "x_access_task" , "u_field=someVlue" , function(response) {

var record_id= response.data.sys_id+'';
if(record_id == c.data.sys_id){
 spUtil.update($scope);

}
});

lakhrissihasna
Tera Contributor

I don't know if there is a better solution, but I found the same issue and a workaround that worked for me is to put a filter on other fields than the sys_id, then in the record watcher add a condition on the sys_id. Something like this :

var c = this;

spUtil.recordWatch($scope, "x_access_task" , "u_field=someVlue" , function(response) {

var record_id= response.data.sys_id+'';
if(record_id == c.data.sys_id){
 spUtil.update($scope);

}
});