Need an UA old-timer

I have a client with an old old old UA (4.0.2 Rev E) they won't pay to update. A problem has appeared and if I describe it, perhaps it will fire someone's long dormant neurons...

I did not write this PRD but have now put in 5 hours adding debug code and experimenting with it to try and get it to behave. This is far from my first PRD, I've done stuff like this hundreds of times, so the behavior is inexplicable and clearly a bug, I just am hoping someone remembers a workaround.

To summarize, the PRD looks up a user, starts filling in some fields, all is joyful. They then fire a custom event and in the event handler read an attribute (L) and semantically build the DN of an object (meaning it assembles it from the value using string concatenation) which is used in a to select a picklist item.

This is where things get wonky. I get everyone's favorite red error in the form referencing IDVault.get() getting the string "undefined" back as the value of the object returned from the DN. Ok, so I figure the DN is coming back wrong, but it was used correctly in a whole bunch of IDVault.get()'s back when things were happy happy joy joy (a few precious miliseconds earlier).

Now we enter the twilight zone, if I display the DN with a form.alert() right before the IDVault.get(), it all  works. Actually there is another detail, we realized that it turns out if you are really quick on the draw of clicking OK you can still experience the failure. But if you wait a second or so it works.

So it's a timing issue; I tried putting in a sleep loop which didn't work (I think we are just keeping the javascript in the browser busy but not moving the processing forward).

I guess my question here is if anyone knows a way to tell the browser to keep processing background threads like it does while it's waiting for you to dismiss the alert dialog while holding in a loop so that we can workaround this timing issue.  I almost want to just pop up an animated hour glass for couple of seconds...

Just trying to find a way to resolve this without resorting to rocket surgery...




  • Solved the problem myself.

    The root issue is still probably a bug in IDM 4.0.2. But the workaround was to insert a delay before the IDVault.get() that was failing. The call that was failing was place inside an event handler and inside a try-catch block (which was ineffective, it did not catch anything even though I got a red-error).

    Instead of just a form.fireEvent() call, the call was made this way:

    setTimeout(function() {field.fireEvent("locselect");}, 5000)

    This added a 5 second delay.

    For good measure, added a test in the event handler that if I still got an "undefined" back from IDVault.get(), I would fire the event again in 1 second. So even when it fails, it works eventually.

    In my testing, it seemed like it takes between 3-5 seconds delay to make this work without error. Again clearly a bug, but until the client ponies up to upgrade this is the best I can do.