Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

GlideScriptedProgressWorker runs but Script Include logic not executing (no records inserted)

Harsh_Hirani
Tera Contributor

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_worker record 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:

  1. Is there something missing in the worker configuration?

  2. Does GlideScriptedProgressWorker behave differently when triggered from Scripts - Background?

  3. Is there a recommended way to debug worker execution?

Any help or suggestions would be greatly appreciated.

Thanks!

0 REPLIES 0