7 Replies Latest reply on Aug 7, 2009 7:15 AM by RayMentor

    The Mysterious SELF Function

    RayMentor

      Title

      The Mysterious SELF Function

      Post

      OK, call me crazy, but I can't for the life of me understand WHAT the Self function really does and how to apply it.  The example given in the official FM Help file refers to:

       

       

        Exampleself > 10 returns 1 (true) when applied to a layout field object whose value is greater than 10.

       

      This leaves me with the obvious question of "what's a layout field object?" Is this just a field on any layout? If so, what would an example of a SELF function look like when it is "applied" to a field?

       

      Help appreciated. 

       

        • 1. Re: The Mysterious SELF Function
          mrvodka
              For example, a very useful place to use Self would be in a conditional format. You can basically copy and paste the formula for multiple field objects if you want the same condition to work on each one instead of explicitly referring each individual field.
          • 2. Re: The Mysterious SELF Function
            RayMentor
              

            Thanks for your reply.  Unfortunately, I don't understand your explanation. Sorry.

             

            Could you give me a simple example of what the SELF calculation would look like in the "worksheet" area of the calculation definition box??

            • 3. Re: The Mysterious SELF Function
              mrvodka
                

              Here is even a more simple example.

               

              Create a number field, lets call it num1 in a table called Table. Then put in a validation by calculation of Self > 10.

              Now try to enter a value of 9. The validation will fail and you will get a message.

               

              Now create another number field, lets call it num2. Put in a validation by calculation of Table::num2 > 10.

              Now try to enter a value of 9. The validation will fail and you will get a message.

               

              In both cases it will work.

               

              Now type in 11 into both num1 and num2.

              Next duplicate both fields in the table. Now you should have num1 Copy and num2 Copy.

               

              Try to put 9 in both fields. num1 Copy will fail and num2 Copy should not as it still refers to num2 in the validation.

               

              • 4. Re: The Mysterious SELF Function
                comment_1
                  

                RayMentor wrote:

                Could you give me a simple example of what the SELF calculation would look like in the "worksheet" area of the calculation definition box??


                It depends on what exactly are you trying to calculate. For example, Self is meaningless in a formula of a calculation field, because Self refers to the field's value - and the field's value is the result of this very calculation. But if you were specifying the formula for a field's 'Auto-enter calculated value', you could use Self + 1 to make the field increment by 1 on each evaluation.

                 

                 

                A more practical example in the same context (i.e. auto-entered calculated value) would be Trim ( Self ). This will remove any leading/trailing spaces the user might have entered into the field.

                 

                If the field were named FirstName, then Trim ( Self ) would accomplish the same thing as Trim ( FirstName ). But if you duplicate the field and rename the copy as LastName, there will be a big difference between the two: if you used Trim ( FirstName ), you now need to change the auto-entered formula to Trim ( LastName ); whereas Trim ( Self ) will always refer to itself. i.e. to the value of the same field where it's being used.


                • 5. Re: The Mysterious SELF Function
                  RayMentor
                    

                  Big thanks to MrVodka and Comment for throwing light in the darkness.

                   

                  Surprising that the example of the SELF function in the official FM help file is so abstract in comparison to the clear examples you both graciously described.

                   

                  I see that in both your examples the SELF function is used as a validation NOT as a standalone function like

                  Sum() or If() or Trim() that would define a separate field. The use of SELF function as a validation makes all kinds of sense now. I'll definitely use the application of the SELF function for trimming out extra spaces as in Comment's example.

                   

                  I really appreciate you both taking time to clear this up. Give yourself a raise and take the rest of the day off;)

                  • 6. Re: The Mysterious SELF Function
                    comment_1
                      

                    RayMentor wrote:
                    I see that in both your examples the SELF function is used as a validation

                    My example isn't, and neither is mr_vodka's earlier example of conditional formatting. The point here, I think, is that Self has a meaning only in a context where "self" has (or can have) an intrinsic value. Thus you cannot use Self in a script for example, because a script has no value attributed to it.

                     

                     


                    RayMentor wrote:
                    Surprising that the example of the SELF function in the official FM help file is so abstract in comparison

                     

                     Sad perhaps, but hardly surprising...



                    • 7. Re: The Mysterious SELF Function
                      RayMentor
                         Yes, I misspoke when I characterized your example as "validation". I got that it did its thing upon field entry and it is auto-entry option, not a validatation per se. My brain was disconnected from my typing fingers at the time.....