Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Error Trapping failing when trigger scripts run

Featured Replies

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

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?

  • Author

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

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 …

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.