AnsweredAssumed Answered

How Do I Find the Correct Name for "Set Field by Name"?

Question asked by richardsrussell on Dec 8, 2017
Latest reply on Dec 13, 2017 by richardsrussell

Here are the desiderata. Data-entry people have to enter telephone numbers, either by typing or pasting. If they have a local number like 234-5678 (7 digits + hyphen), fine. If they have a longer number like 987-654-3210 (10 digits + 2 hyphens), also fine. But we have some folx who are adept at using the numeric keypad and would prefer to type in just the digits (9876543210 in the above example) and have FileMaker Pro insert the hyphens for them automatically.


Seemed like a reasonable request, so I set about creating a script to do it. Here it is, set up to be triggered "OnObjectExit" from the "Phone Number" field it happens to be in at the time:


Format Phone Number Script.jpeg


And it worked fine for the one and only "Phone Number" field that existed on my original layout.


But then I added a "Phone Number" field from a related table and got bizarre results. Here's what happened when I started data entry and had gone as far as putting "1234567890" into the "Phone Number" field for "This Table":


Formatted Local Field.jpeg

As you can see, it correctly inserted the hyphens before moving on to the "Next Field". I then tabbed to the "Phone Number" field from the related "Other Table" and entered "9876543210", which produced this surprising result:


Unformatted Related Field.jpeg

It was surprising for 2 different reasons:

     (1) It hadn't formatted the field it had exited from ("Other Table::Phone Number").

     (2) It had replaced the already entered value from the local table ("This Table::Phone Number").


Clearly, I was doing a terrible job of establishing the proper name for that "Set Field by Name" step. So I set out on safari to see if I could find a "Get" function that would return a fully qualified field name, complete with the leading name of the proper table occurrence (TO). These 2 functions suggested themselves:


Get AF Table Name.jpeg  Get AL Object Name.jpeg


I then created a script to display what they returned upon exiting from the "Phone Number" field:


Display Values Gotten Script.jpeg


Here's what I got upon exiting from "This Table::Phone Number":

Values Gotten.jpeg

As you can see, "Get ( ActiveLayoutObjectName )" didn't have a clue what the active layout object was, but at least it got the "ActiveFieldName" and "ActiveFieldTableName" right.


I then tried exiting from "Other Table::Phone Number" and got the exact same results as before. That is, still no idea what "ActiveLayoutObjectName" might be, but this time it didn't even recognize that the "ActiveFieldTableName" was supposed to be at least "Other Table", let alone the actual name of the TO as defined in the relationship.


So my basic question is this: How can I persuade FileMaker Pro to spit out for me a fully qualified field name (complete with proper leading TO name) that I can plug into a "Set Field by Name" script step?