Record Watcher not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 12:45 AM
I am tying to retrieve the status of a field from a table for a new record using record watcher but it won't work. I have added spUtil at header and added an alert statement at watcher function but nothing is being logged.
Any idea's why?
The code
spUtil.recordWatch($scope, "tableName", "sys_id" +c.orderId, function(response) {
// Returns the data inserted or updated on the table
alert("orderId 1 " +c.orderId);
c.data.action = 'orderUpdationCheck';
c.data.orderId = c.orderId;
c.server.update().then(function(response){
c.data.action = '';
if(response.ordered)
$window.location.href = c.data.portalLandingURL;
});
});
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 04:08 AM
The filter is not OK; it should be:
"sys_id=" + c.orderId
notice the extra =
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 04:14 AM
Hello
if you are getting your order id from server you need to write it as
spUtil.recordWatch($scope, "tableName", "sys_id="+c.data.orderId, function(response) {
// Returns the data inserted or updated on the table
alert("orderId 1 " +c.orderId);
c.data.action = 'orderUpdationCheck';
c.data.orderId = c.orderId;
c.server.update().then(function(response){
c.data.action = '';
if(response.ordered)
$window.location.href = c.data.portalLandingURL;
});
});
if it is client side variable where you stored you order id it should be like below
spUtil.recordWatch($scope, "tableName", "sys_id="+c.orderId, function(response) {
// Returns the data inserted or updated on the table
alert("orderId 1 " +c.orderId);
c.data.action = 'orderUpdationCheck';
c.data.orderId = c.orderId;
c.server.update().then(function(response){
c.data.action = '';
if(response.ordered)
$window.location.href = c.data.portalLandingURL;
});
});
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU