Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3734 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I was puzzled when a test for a script error failed in the following situation:

 

Set Error Capture [On]

Go to Layout ["Billings" (Billings)]

Enter Find Mode[]

Set Field [billings::InvoiceDate; Date(1;1;1900)]

Perform Find []

Set Variable[$error; Value:Get(LastError)]

If [$error > 0]

Exit Script [Result:TRUE]

End If

 

The problem was that in some cases the Find found no records, but the $error variable remained empty. The problem was traced to a trigger script attached to the layout Billings, which was set to trigger on Record Load.  The trigger script has the effect of 'swallowing' the error code generated when the Find fails, and by the time control returns to the Set variable step following the Find, the get(LastError) function returns a value 0.

 

The easy solution was to create another layout based on Billings which had no script triggers associated with it and carry out the Find on that layout.  However I'm intrigued where else trigger scripts can cause a similar problem and if there is a way of catching the error before the trigger script runs.  Ideas?

 

Thanks

 

Brian

Posted

The easy solution was to create another layout based on Billings which had no script triggers associated with it 

 

Wouldn't it be easier to just check for an empty found set?

Posted

In the example I gave, yes, but I wanted to trap for other errors as well in the situation I was working in.   In practice, to make sure that it was the trigger script causing the problem,  I created the other layout and it was easiest to leave it in situ . 

 

I only noticed the problem when I was stepping through the failiing code in the debugger and saw that although the found set was empty, the last error code was 0. The point of interest for me is how to trap errors in this kind of situation. 

 

Brian

Posted

The point of interest for me is how to trap errors in this kind of situation. 

 

I guess in this case you can't reliably. The last step of the triggered script writes into the global error register, and you can't capture the error state immediately before the start of the trigger script.

 

Interestingly, the OnRecordLoad step is even triggered if there is no actual record to load (empty found set). I tested by making the trigger immediately exit on an empty found set; in that case, no error code is written, and the subsequent 401 is captured correctly.

 

Apart from using that workaround (?), you probably have to either test explicitly for the error conditions you're interested in, or employ a global switch for your triggers (which is a good strategy anyway) that you set to off when you don't need them, then back on again.

 

All in all, in your case it maybe was the easiest way to create a new, dedicated search layout …

This topic is 3734 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.