AnsweredAssumed Answered

onRecordLoad oddity

Question asked by _ian on May 1, 2009
Latest reply on May 11, 2009 by philmodjunk

Summary

onRecordLoad oddity

Description of the issue

I'm still undecided if this is a bug or not. I think at the very least it's an omission in the implementation of script triggers. One of our guys picked up an interesting little bug today.He was using get(lasterror) to check the results of a find and discovered that he was getting error code 0 in situations he was expecting an error code. It turns out that he's been using an OnRecordLoad fired script. His scripted find returns 0 records due to a 401 error, but OnRecordLoad fires even though there is no record to load. As soon as the event fires it seems to be clearing get(lasterror) before he can populate his $last_error variable because it is evaluating script steps. tracing in script debugger you can see the error code, but there seems to be no way to retrieve it in a script.So onRecordLoad is firing even if there are no records in the found set to load. The problem is that it seems to prevent any effective way of capturing errors from a failed Find script step. It only leaves us with checkiing the found count, which while it lets us know that there are no records, it's not very helpful in determining *why* we've got no records returned from a Find. It would be extremely useful to have some means of returning a result from a script trigger. But this would presumably require redoing script triggers to function more like events in other programming languages. Which would be a really really good thing, but I do realise isn't going to happen anytime soon.  regardsIan  

Outcomes