4 Replies Latest reply on Jan 12, 2017 1:38 PM by Malcolm

    obtain internal id function not working

    tomswell

      I downloaded the following function from Brian Dunning site > FileMaker Custom Function:IDFromName ( _Name ; _Type ; _File )

       

      /* Type must be either Layout, Script, Table, Value, or, for Fields, supply layout via "Type"

      File defaults to current if you don't specify

      */

      Let (  [

       

      // File defaults to current

      _Fn = If ( IsEmpty ( _File ) ; Get ( FileName ); _File );

       

      _IDs = Case( _Type = "Layout"; LayoutIDs ( _Fn ) ; _Type = "ValueList" ; ValueListIDs ( _Fn ) ; _Type = "Script" ; ScriptIDs ( _Fn ) ; _Type = "Table" ; TableIDs ( _Fn ) ; FieldIDs ( _Fn ; _Type ) ) ;

       

      _N = Case( _Type = "Layout"; LayoutNames ( _Fn )  ; _Type = "ValueList" ; ValueListNames ( _Fn ) ; _Type = "Script" ; ScriptNames ( _Fn ) ; _Type = "Table" ; TableNames ( _Fn ) ; FieldNames ( _Fn ; _Type ) ) ;

       

      _p1 = Position ( "¶" & _N & "¶" ; "¶" & _Name & "¶" ; 1 ; 1 ) ;

      _n1 = Left (_N; _p1 ) ;

      _p2 = ValueCount (_n1 ) ] ;

      If ( _p1 ; GetValue ( _IDs ; _p2 ) )

      )

       

       

      while having appropriate table open

      entering this in data viewer yields nothing;

       

      IDFromName ( table name::field name ;"Layout"; Get ( FileName))

      or

      IDFromName ( table name::field name ;"Layout"; "")

       

      I'm close  .... what am i doing wrong ?

        not sure how to interpret "Type must be either Layout, Script, Table, Value, or, for Fields, supply layout via "Type"

      I wish to create a field $identifier so as to be able to return to the table field on layout i have previously left,

      using internal field id an alternative to using field name as reference.

       

      ... seems there's a lacking FM function Get(ActiveField_Internal_id)

        • 1. Re: obtain internal id function not working
          TSGal

          tomswell:

           

          Thank you for your post.

           

          What values to you get for each of the variables inside the Let function?  For example, what is the result of _Fn?  If the value in _Fn looks correct, then continue with the remaining variables.

           

          Try putting these values into fields to make sure it works before moving it to a custom function.

           

          TSGal

          FileMaker, Inc.

          • 2. Re: obtain internal id function not working
            tomswell

            I'm not too sharp with deconstructing the let statement:

             

            my crude understanding is ..   Let ( [declare values]; calc(s); result)

             

            let statement deconstruct.png

            Since if I'm after field id only i should be able to negate some of the element declaring that doesn't apply.

            It's unclear as to how to test

            declaration1  > don't need it if i hard wire Filename

            declaration 2  > type= "Layout" so _Fn = "LayoutIDs" ;  FieldIDs = "LayoutIDs";"Layout"

            declaration 3 > type= "Layout" so _Fn = "LayoutNames" ;  FieldNames = "LayoutNames";"Layout"

            • 3. Re: obtain internal id function not working
              TSGal

              tomswell:

               

              Create separate calculation fields for FN, ID, N, p1, n1 and p2.  This should probably give you an idea what is not working.

               

              TSGal

              FileMaker, Inc.

              • 4. Re: obtain internal id function not working
                Malcolm

                tomswell,

                a bit of critical thinking is needed to solve the problem

                1. This isn't a product issue is it?
                2. Custom Functions posted to public web sites generally work. If not, approach the author.
                3. If a function that is known to work fails for you then you aren't feeding it the right food.
                4. you say you are sending the table::field. If that field reference can be resolved it will send the data found inside the field, not the field name.
                5. use GetFieldname( table::field ) to get the field name

                 

                malcolm