7 Replies Latest reply on Dec 17, 2012 11:19 PM by comment

    auto calc self name

    rivet

      might not be thinking straight today, but in a auto enter calculated value, I am trying to get the name of Self to include in a string. possible??

       

      The idea is there are many sets of fields, a global and a stored for each.

      The full name of the stored field is the suffix of the global field:

      global_dog

      dog (which is stored)

       

      And since there are so many pairs, I would like the calc to be dynamic.

       

      Calc Example for 'global_dog':

      "table::" & GetFieldName(rightwords( self ; 1 ))

        • 1. Re: auto calc self name
          comment

          I don't follow your explanation.

           

          it seems to me that if you have "many sets of fields" you probably have a structural issue. Especially when the field names are significant, i.e. they reperesent data.

          • 2. Re: auto calc self name
            DavidJondreau

            Heed comment.

             

            Structure aside, I think you're missing two pieces. GetFieldName() shouldn't be used here. And you need an Evaluate() wrapped around everything. The Self function can be tricky, but this might work.

             

            Evaluate ( "table::" & RightWords ( Self ; 1 ) )

            • 3. Re: auto calc self name
              comment

              RightWords ( Self ; 1 ) looks at the contents of the field. I suspect OP wants to fetch the last word of the field's name, something like =

               

              GetField ( RightWords ( GetFieldName ( Self ) ; 1 ) )

               

              The problem with this approach - apart from what I mentioned in my previous post - is that there is nothing here to trigger an evaluation, since no field is referenced in the formula. The idea that the field can be duplicated as is and only its name changed just won't work.

              • 4. Re: auto calc self name
                ErikWegweiser

                First, I'm impressed that GetFieldName( self ) does actually return the desired result; the table and name of the field in which the calculation exists.

                Secondly, I'm not sure about "global_dog" being a global... or unstored calculation?... and when its value is supposed to be triggered to update?

                 

                Regardless — again, structure and purpose aside — perhaps what you're looking for is this:

                 

                Evaluate( Substitute( GetFieldName( Self ); "global"; "stored" ) )

                 

                You might even create a custom function, like: fn_selfstored( field_name) [= Evaluate( Substitute( GetFieldName( field_name ); "global"; "stored" ) ) ]

                and make the calculation for each field simply be fn_selfstored( self )

                 

                Anyway, I hope this points in a favorable direction for you.

                • 5. Re: auto calc self name
                  rivet

                  MH - its just a table for ui icons. I keep one in storge and a copy in globle. for various reasons.

                  • 6. Re: auto calc self name
                    rivet

                    Thanks guys for your help, Seems like it should be a simple thing to get the name of Self. I will kepp playing.

                     

                    Perhaps I should have named the thread "Who am I"?

                    • 7. Re: auto calc self name
                      comment

                      rivet wrote:

                       

                      MH - its just a table for ui icons. I keep one in storge and a copy in globle. for various reasons.

                       

                      I suspect that  a repeating field could provide a much better solution than the contraption you are trying to build.