Alex Stockwell

UX, DevOps, Fatherhood, Miscellany. Not in that order.

How To Execute Workflow Activities with Custom Delays in NetIQ’s Identity Manager User Application

I’ve been looking for a clean solution for instituting a delay/sleep/wait in a UserApp workflow for a while now. There is a cool solution that demonstrates an approach to doing this with a dummy Approval activity, but I felt like it was pretty convoluted, and didn’t like how it polluted the comments log with approval notifications that are just going to confuse users.

So reaching across into the Java world, Thread.sleep() was a perfect candidate for this use case. After some searching and trial-and-error for integrating with the Rhino ECMAScript implementation, I arrived at this snippet:

try {
    java.lang.Thread.sleep(8000);  //units are milliseconds: 1000 = 1 second of sleep time
} catch(ex) {
    java.lang.System.out.println("Encountered error trying to sleep: " + ex);

I’ve used it without issue in Condition and Mapping activities, and I assume it will work anywhere else ECMAScript is used. Technically you don’t even need the try/catch block, it’s just best practice. java.lang.Thread.sleep(8000); worked fine in my limited testing.

One implementation gotcha: if you’re not using IIFEs and explicit return values, you can’t leave sleep() as the very last thing in the ECMAScript editor, since the workflow will respond that you’re not returning anything and it will throw an error. Just move the sleep() call to the top of the ECMAScript editor and it works perfectly.

This was tested in the Identity Manager 4.0.2 UserApp.