GlideScriptedProgressWorker runs but Script Include logic not executing (no records inserted)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I’m trying to execute a long-running task using GlideScriptedProgressWorker, but the Script Include logic does not seem to run. The worker record gets created in sys_progress_worker, but the code inside the Script Include is not executing.
Expected behavior:
The Script Include should insert records into the Incident table and update the progress message.
Actual behavior:
A
sys_progress_workerrecord is created.No errors appear in the logs.
No records are inserted into the Incident table.
gs.info()logs inside the Script Include do not appear.
Worker Script:
var worker = new GlideScriptedProgressWorker();
worker.setProgressName("Data Processing Task");
worker.setScriptIncludeName("CustomDataProcessor");
worker.setScriptIncludeMethod("runHeavyTask");
worker.putMethodArg("targetId");
worker.setBackground(false);
worker.start();
gs.info(worker.getProgressID());Script Include:
var CustomDataProcessor = Class.create();
CustomDataProcessor.prototype = {
initialize: function () {},
runHeavyTask: function(progress, recordId) {
var iterations = 10;
for (var i = 1; i <= iterations; i++) {
gs.info(i);
var percent = (i / iterations) * 100;
progress.setProgressPercent(percent);
progress.setMessage("Processing batch " + i + " for record: " + recordId);
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = "worker test";
gr.insert();
gs.sleep(1000);
}
progress.setMessage("Task Completed Successfully!");
},
type: 'CustomDataProcessor'
};Additional details:
Script Include is Server-side.
Script Include is Accessible from All Application Scopes.
The worker is triggered from Scripts - Background for testing.
Questions:
Is there something missing in the worker configuration?
Does
GlideScriptedProgressWorkerbehave differently when triggered from Scripts - Background?Is there a recommended way to debug worker execution?
Any help or suggestions would be greatly appreciated.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Does the same issue occur if you use GlideScriptedHierarchicalWorker?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
There are a few problems in your code. Please refer below:-
In your worker script, you are calling:
worker.putMethodArg("targetId");However, putMethodArg() requires both a parameter name and a value, and the name must match the parameter defined in the Script Include method.
Should be:-
worker.putMethodArg("recordId", "someValue");
Your Script Include method is defined as:
runHeavyTask: function(progress, recordId)So the worker should pass recordId as the argument.
setBackground(true) is generally recommended when triggering the worker from Scripts - Background. you have set it to false in your script.
Once the argument name and value are passed correctly, the Script Include method should execute and you should start seeing the expected logs and incident records being created.
Hope this helps!
