AnsweredAssumed Answered

Set Field not working for new related record in script trigger

Question asked by Timothy Bentley on Jul 16, 2015
Latest reply on Jul 17, 2015 by TSGal

Summary

Set Field not working for new related record in script trigger

Product

FileMaker Pro

Version

13.0.5, 14.0.1

Operating system version

Windows 7

Description of the issue

When entering a value in a related field (not in a portal) when the related record doesn't exist yet, if the script that runs on OnObjectModify or OnObjectValidate uses Set Field for that field, it does not initially work.

I find the last step below particularly interesting, it suggests...something strange.

Steps to reproduce the problem

Create a table Test with an auto-enter serial field pk and a table Test2 with fields fk, TextField, and DateField. Relate the tables allowing record creation matching pk and fk.

Create a script SetDateField with the line Set Field [Date(1; 1; 2015)] (inserting the field name makes no difference) and a script SetTextField with Set Field ["Test"] and Exit Script[].

Create a layout based on Test with Test2::TextField and Test2::DateField. Add a portal for Test2 with TextField and DateField. Set script triggers for OnObjectValidate (or Modify) for each field with the appropriate one.

Create a new record and type 1 into the portal fields and note the triggers work correctly.

Create a new record and type 1 in TextField with Script Debugger and tab out. Note that after the set field 1 stays in the non-portal field while the portal value changes. After the script ends the portal field reverts to 1. Type 1 in DateField and note it works correctly.

Create a new record and type 1 in DateField and tab out. Note that 1 stays in the non-portal field while the portal value changes. Click OK then tab out again and it works correctly.

Repeat the previous step but choose revert record and the date "reverts" to 1/1/2015.

Expected result

Values will change when Set Field is called.

Actual result

Values don't change.

Exact text of any error message(s) that appear

When applicable, the normal date validation error.

Workaround

Perhaps the simplest is to put the field in a one-line portal.

Outcomes