Service Portal: Dynamically load data in the widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 02:39 PM - edited 02-14-2025 03:15 PM
Hello Community,
In my Widget Server script, when user clicks on "onDemand Preflight check" button I trigger a workflow that typically takes around 6 minutes to complete.
Q: How can I dynamically load new content when the status of the workflow changes to "completed"?
Q: Is using recordWatch() the correct approach to implement this functionality, or are there any better alternatives? If I apply recordWatch() on a table with a filter condition (such as looking for a specific state), it will monitor all records in that table. How can I target a specific record, for example, by sys_id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 06:52 PM - edited 02-19-2025 06:53 PM
Alternatively, I tried below code.. I don't think scope is getting updated. any suggestions how to load data dynamically?
// Initialize a counter variable
var refreshCount = 0;
var maxRefreshes = 3; // We want the widget to refresh 3 times
// Function to refresh the widget
function refreshWidget() {
if (refreshCount < maxRefreshes) {
// spUtil.refresh() will refresh the widget content
//spUtil.refresh();
//spUtil.update($scope);
c.server.update();
// Increment the counter
refreshCount++;
console.log('Widget refreshed ' + refreshCount + ' times.');
// After 3 refreshes, stop the interval
if (refreshCount === maxRefreshes) {
console.log('Maximum refreshes reached. Stopping the refresh cycle.');
$interval.cancel(refreshInterval); // Stop the interval after 3 times
}
}
}
// Set the interval to call the refreshWidget function every 1 minute
var refreshInterval = $interval(function() {
refreshWidget();
}, 60000);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 08:58 AM
Record watch isn't supported on wf_context. It's blacklisted by default and enabling it can cause performance issues.