Need more info on GlideScriptedProgressWorker, if we can wait for thread to finish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 11:38 AM
Hi All,
We have created the class GlideScriptedProgressWorker and we are staring the thread.
var worker = new GlideScriptedProgressWorker();
worker.start();
it appears that it is staring a thread in the background and flow continues.
Is there any way, I can wait for worker to finish before we proceed to next activity ?
what all methods are available for the object of this class ?
will normal thread.join kind of methods work ?
Thanks in advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 12:31 PM
Anoop, Thanks for the question. While I don't know the answer, I want to understand why did you use GlideScriptedProgressWorker, meaning as I never came across the usage of this Class, I want to understand what's the use case that you are trying to complete by using this?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 11:08 PM
Hi Abhiram,
SN is using this when we do a preview of an update set.
We want to do a sequential preview of update sets and hence running this code in a loop so that we just give a set of updatesets and it does the preview of all of them at one go.
It doesn't work for some reason i.e. it does the preview of first update set but doesn't do the preview of subsequent update set.
SN OOB UpdateSetPreview script include and Preivew Update Set UI action has code around that.
Thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 11:21 PM
Anoop, you might want to preview and commit the first one, then preview the second one. You can use the code below to do it one by one, just make sure you pass the retrieved update sets sys_id in the while loop:-
var worker = new GlideScriptedProgressWorker();
worker.setProgressName("Generating Update Set Preview for: " + <update sets name here>);
worker.setName('UpdateSetPreviewer');
worker.addParameter(<sys_id of your retrvd update set>);
worker.addParameter("preview");
worker.setBackground(true);
answer = worker.getProgressID(); // set answer to the progress worker ID BEFORE worker starts
worker.start();
This will initiate the preview, now you can put a query here to stall till this one completes (you can check the progress worker table to see if the preview got finished)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2015 01:23 AM
There is a wait methods.
See list below, although I don't know what parameters they take.
initProgressFields
setCannotCancel
setProgressState
toString
wait
cancel
registerChild
getClass
setProgressStateCode
hashCode
stage
fail
notify
setProgressName
setParentController
setProgressErrorState
getParentController
isCancelled
getOutputSummary
updateDetailMessage
run
getProgressMessage
start
isUncancelable
setProgressTable
equals
getProgressState
runScript
updateMessage
setProgressError
addNonEscapedParameter
isFailed
addMessage
setProgressMessage
addParameter
setBackground
success
setName
notifyAll
isBackground
isPending
getWorkerThreadID
isError
getProgressID
setOutputSummary
isStarting
loadProgressWorker
getProgressTable
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022