Jump to content
Server Maintenance This Week. ×

Replace Field Contents script step discovery


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

Recommended Posts

Apologies if this discovery has already been posted by someone; I searched, and believe it has not.

Anyway, I've discovered that -- contrary to what is stated in FileMaker 7 Help, as well as my current, beloved FM bible "Special Edition Using FM 7" -- the "Replace Field Contents" script step does not require the specified field to be on the current layout (i.e., the one from which the script step is performed). The current layout must apparently be either based on the base table of the specified field or a related table occurence, to avoid an error, but in neither case does the field need to actually be on the (or any!) layout. In this way the behavior of this script step is similar to Set Field, which also does not require the field to be on the layout and is highly valued for that fact. (I think there'll be little disagreement with that statement!) But wait there's more...

If the current layout is based on the specified field's table, then the replace operation is performed on all records in the found set (just as expected, except for the part about the field not needing to be present).

If, however, the current layout (call it 'B') is based on a related table occurence 'B' (again with no requirement for the field itself to be shown), then the replace operation is performed on all records in table 'A' (i.e., the specified field's table) that are related to records in the current found set in 'B', regardless of their inclusion in any particular found set in the field's own table 'A'. (If someone can translate into a clearer description, please be my guest.)

It's a bit confusing, a bit counter intuitive, but very nifty none-the-less, and will definitely change the way I think about using "Replace Field Contents" in a script.

I haven't compared this to the behavior in FM 5 / 5.5 / 6, although I beleive those versions did indeed require the specified field to be on the layout. If so, this is an interesting behavior change, yet to even be noticed by the folks who write the Help files.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Interesting.

Question: Does this mean that there is a quick 2-step to duplicate the primary keys in one table to another?

Let's say you have table A, and you want to make sure that table B has a one-one relationship with table A. Could you just do this?

Go to layout (table A)

Find (find for Key_A::Key_B = null)

ReplaceFieldContents (Key_A::Key_B; Key_A)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

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