13 Replies Latest reply on Aug 27, 2012 9:26 PM by philmodjunk

    Get FieldName Problems

    CountryBoy1

      Title

      Get FieldName Problems

      Post

      Trying to obtain information as to what record, field, and value was last set.  Using the Evaluate
      function and can get the latest record.  Cannot get the latest field name.  Have tried several
      ways.  If I use Evaluate( GetFieldName(Evaluate(Get(ActiveFieldName)));[ etc. , I get the value in the field.

        Strangely, when I use Evaluate( Get ( ActiveFieldName );[ etc., I also get the value in the field
      and not the field name.  Using Filemaker Pro 11 Advanced.  Windows 7, 64 bit OS.

       Thanks for your help.  CountryBoy1

       

        • 1. Re: Get FieldName Problems
          davidanders

          "Trying to obtain information as to what record, field, and value was last set."

          Meaning last modified?
          A Date field can be set to "Auto-entered, Modified Date" in Field Options.
          This will allow you to view and sort the Modified Date (and or Modified Time) for the Record, not the fields.

          Audit Trails are difficult to create, some plug-ins offer simple versions, none of the free plug-ins I know of.

          • 2. Re: Get FieldName Problems
            philmodjunk

            when I use Evaluate( Get ( ActiveFieldName );[ etc., I also get the value in the field

            Well that's what evaluate is supposed to do. If you pass it a field name, it evaluates it--returning a value.

            Remove the evaluate functions and just use the Get functions to extract the active field name.

            • 3. Re: Get FieldName Problems
              CountryBoy1

                 Just using Get (ActiveFieldName) won't work.  I need Evaluate to act as a trigger
              when any one of several fields are changed.  However, "Evaluate" causes the
              value of the just-changed field and not the name of the just-changed field to be
              entered into the "FieldName" field.

                 I could use a script trigger for everyone of the several variables and have them
              put their field name into the "FieldName" field.  The "FieldName" field contains
              the name of the most recent field that had it's value changed.

              .. CountryBoy1

               

               

              • 4. Re: Get FieldName Problems
                philmodjunk

                But do you need to use evaluate in this specific script step? Can't use use evaluate in one step to "trigger" your updates and not use Evaluate in the step where you need the table occurrence and field names of the currently active field?

                Can you describe exactly what triggers you need to trip with that evaluate function?

                If you really want to do it all in one step, you might do this:

                Let ( [ FieldRef = Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) ;
                          Dummy = Evaluate ( FieldRef )  // this should produce the same result in terms of "triggering" auto enter calcs--my guess as to what you mean
                        ];
                        FieldRef
                       )

                • 5. Re: Get FieldName Problems
                  CountryBoy1

                  Tried the code from PhilModJunk but no results.  Tried both "calculated field" and "text field with calculation".
                  Can't get the Get (ActiveFieldName) function to work under any circumstances.

                   

                  ... CountryBoy1

                   

                  • 6. Re: Get FieldName Problems
                    schamblee

                    I Created a test Field call FieldChanged.  I have another field ProductCode  I also created a script "Get Field Name" with the Following line.

                    Set Field[Products::FieldChanged;GetFieldName(Evaluate(Get(ActiveFieldName)))]

                    I then set a script trigger (OnObjectModify) on the ProductCode to run the above script "Get Field Name". 

                    This return the "Products::ProctCode" into the field FieldChange

                    • 7. Re: Get FieldName Problems
                      philmodjunk

                      Check to make sure that the field is really active.

                      The cursor must be in the field at the time that the script step with the get ( active...  function executes or it is not the "active" field.

                      • 8. Re: Get FieldName Problems
                        CountryBoy1

                        S Chamblee has a solution.  I wrote my own code and it works.  It's too bad
                        that I have to specify a trigger script for 32 different fields instead of getting
                        the changed-field to pick up the name of the field that was changed.  I just
                        couldn't get Get (ActiveFieldName) to work inside of a field calculation.  However
                        it does work in a stand-alone script (program) and that is what I will use as
                        my trigger script for all the 32 different fields.

                        • 9. Re: Get FieldName Problems
                          philmodjunk

                          One script should work for all 32 fields. If your are setting up the field as a button so that clicking it performs your script, that explains why get ( ActiveFieldName ) doesn't work. Clicking such an object never makes it "active". The cursor must be in the field for it to be active and the button setup prevents that from happening.

                          You still do not need 32 different scripts, however. you can use GetFIeldName as a script parameter passed to your script and specify a different field name with each use of this script in the optional script parameter box.

                          Then Get ( ScriptParameter ) will return the table::field text.

                          • 10. Re: Get FieldName Problems
                            philmodjunk

                            See this demo file: https://dl.dropbox.com/u/78737945/IndirectFieldRefDemo.fp7

                            Field 1 and Field 2 are set up as buttons performing the same script.

                            Field 3 uses the OnObjectEnter script trigger and the Get ( ActiveFieldtableName ) & "::" & Get ( ActiveFieldName )

                            expressions.

                            Both scripts set this text in the field just to enter a value for demo purposes.

                            • 11. Re: Get FieldName Problems
                              philmodjunk

                              I private message from countryBoy indicates that he is using the OnObjectSave trigger.

                              The OnObjectSave Trigger is tripped after the field is exited so thus, the focus, as I had suggested is no longer in the field.

                              I have thus updated the demo file to show two ways to get this to work when using the OnObjectSave trigger. The same download link works so you can simply download the demo file a second time to get a copy with these updates.

                              • 12. Re: Get FieldName Problems
                                CountryBoy1

                                To All: Solution to my earlier Get (ActiveFieldName) Problem.

                                    Found out that if Evaluate ( Get(ActiveFieldName);] ..etc is called, it returns the VALUE in the active field.
                                                          if Evaluate ( "Get(ActiveFieldName)";] ..etc is called, it returns the NAME of the active field.

                                Smile

                                   Sincerely, CountryBoy1

                                 

                                 

                                 

                                • 13. Re: Get FieldName Problems
                                  philmodjunk

                                  true, but why get so complicated?

                                  get (activeFieldName )

                                  Returns the name of the field without using evaluate.