Hello @Bobino,
Happy new year.
I used to try to remain educated with respect to Selector-Connector, but I don't actually use it.
That said, you've done a great job of describing the scenario, and I can relate to it (no pun intended) just from a general sense of FMP and how it tracks and refreshes (or doesn't) relationships.
In particular:
The scenario where a relationship spans two hops, and the second hop employs a predicate which references a global field belonging to the intermediary table (i.e. the middle table of the three chained TO's).
This is a beautiful and crafty setup which requires keeping in mind that extra steps are sometimes required to refresh the relationships, in order for all the data to fall in place as we expect and/or desire.
To be a tad more concrete with an example:
- Given tables and table occurrences: A, B, C
- And a graph that relates A to C, with B in the middle, i.e. A --- B --- C
- And the relationship from B to C involves a global field from B
Then:
- Most of what we might do while in the context of B will behave as we expect, with no extra effort.
This is analogous to how you were able to create multiple child records in your transactions when the script was executed from the "Selector" context.
But, when sitting on the context of A, and wanting to manipulate or display data in C:
- I've always found it necessary to let FMP know if and when the global field in B is updated
- Not doing so can lead to displaying or acting upon the wrong data.
This is analogous to how, while in your non-selector context, the data was getting over-written on one single record when what you had wanted to do was create multiple child records within the transaction.
In order to work around these types of scenarios:
I've always set up the relationship from A to B with a dummy predicate that I can nudge in order to tell FMP to refresh my relationship path. Kudos and credit goes to Daniel Wood (@weetbicks) for sharing this technique (back in the days of around FMP 11, IIRC) -- thanks Daniel!
Nudging the relationship in this way always worked for me when I needed to display accurate child data from C while on the context of A.
My hunch was that the same nudge approach could possibly help with the scenario that you posted. I tested it just now, and it seems to work.
Here is a file to illustrate:
TransactionRelation4Bobino_20190102B.fmp12.zip (72.7 KB)
Please let me know if the file is not clear enough about the approach, and I'll attempt to clarify.
With respect to whether or not you actually wish to employ such an approach:
I could see this getting a thumbs down if the relationship graph is already a tricky or complex one. Adding the pieces needed to nudge the relationship could be the straw that breaks the back of the Camel of Complexity. I'll note that I did briefly try to see if I could refresh the relationship without the use of modifying the graph (instead using script steps such as Refresh Object and Refresh Portal on using dummy fields/portals from C), but my cursory attempts down this path did not work out.
Finally:
I hope this helps. I realize that this explanation is rather lengthy. Sorry about that -- hopefully it is methodical enough to follow, and/or the example file will help connect the dots.
Kind regards,
-steve
p.s. Your description of what you encountered was great. Thanks for making it so clear.