AnsweredAssumed Answered

Get(LastError) clobbered by OnRecordLoad script trigger

Question asked by MattHirons on Nov 3, 2010
Latest reply on Nov 5, 2010 by philmodjunk

Summary

Get(LastError) clobbered by OnRecordLoad script trigger

Product

FileMaker Pro

Version

11.0v2

Operating system version

All

Description of the issue

The value of Get(LastError) is clobbered by an OnRecordLoad script trigger.

For example,
PerformFind[]
<< OnRecordLoad >> script trigger fires here
If [Get(LastError) = 401]
  Do Something
End If

PerformFind generates a 401 error.  The OnRecordLoad script trigger fires after the PerformFind step.  The trigger script does not generate an error, so Get(LastError) is 0 at the end.  When context switches back to the original script, Get(LastError) is still 0, causing existing script functionality to change unexpectedly.  What should happen is that the value of Get(LastError) is restored upon returning from the script trigger.

Steps to reproduce the problem

Create a script (script1) with at least one step in it, such as Set Variable[$$count; Value:1]

Set script1 as the OnRecordLoad script trigger.

Create another script (script2) with the following steps:
Set Error Capture [On]
PerformFind[Restore]  <--make sure this find returns 0 records
If [Get(LastError) = 401]
  Show Custom Dialog ["notice"; "no records found"]
End If

Execute script2.

Expected result

The PerformFind[] step generates a 401 error.
Get(LastError) returns 401.
A dialog is displayed informing us that no records have been found.

Actual result

The PerformFind[] step generates a 401 error.
Get(LastError) returns 0.
No dialog is displayed.

Outcomes