1 2 Previous Next 19 Replies Latest reply on Dec 27, 2011 11:05 AM by LaRetta_1

    Evaluate ("Self")

    DavidJondreau

      Title

      Evaluate ("Self")

      Post

      Is it me or should an auto-enter calculation that includes the following expression work?

      Evaluate ("Self")

      I get an Evaluation Error when trying to run that.

        • 1. Re: Evaluate ("Self")
          philmodjunk

          remove the quotation marks. "Self" is being evaluated as the text self rather then a reference to the current field.

          • 2. Re: Evaluate ("Self")
            rjlevesque

            That is not the correct syntax, there is a logical function which is just Self

            What are you trying to accomplish? Give us a few more details please.  :)

            • 3. Re: Evaluate ("Self")
              rjlevesque

              @Phil, REALLY? That would actually work?

              • 4. Re: Evaluate ("Self")
                philmodjunk

                Yep.

                Granted, I was just noting the incorrect syntax, but I just tried it and I can type in 5 + 5 and Evaluate ( Self ) will replace it with 10 if I have also cleared the do not replace existing values option.

                • 5. Re: Evaluate ("Self")
                  rjlevesque

                  Holycrap...thanks I just learned something cool. Surprised

                  • 6. Re: Evaluate ("Self")
                    DavidJondreau

                    No, for what I'm trying to do, Evaluate ("Self" ) is the correct syntax and should work. I'm trying to call the function Self.

                    Evaluate ( "Self" ) should return the contents of the field it's referencing. In field named table::field, the auto enter calc Self returns the contents of that field and Evaluate ("table::field") returns the contents of table::field. Evaluate ("Pi") returns 3.141...

                    It's useful to reference the current field without it causing a re-evaluation. I currently refer to its own name in quotes (Evaluate ("table::field")), but want to change that so I don't have to worry about changing hard coded field names.

                    Why do I want to do this? I can think of a couple places...I've got an auto-enter calculation that pulls from a related table. I want, as a developer, to make changes to the key field without modifying the existing data. I can set a $$AutoEnterOff to 1.

                    Let( [
                    off = ( $$AutoEnterOff = 1 )
                    id = Name ID ;
                    name = RelatedTable::Name ;

                    thisField = Evaluate ( "Self" ) ;

                    result = If ( off ; thisField ; name )
                    ];
                    result
                    )

                    Or I want a user to enter their own date into DateEnd, but if DateStart is changed, it will picked the higher of the two.

                    DateEnd=
                    Let( [
                    newDate = table::DateStart ;
                    thisField = Evaluate ( "Self" ) ;

                    result = Max (newDate ; thisField ) ;
                    ];
                    result
                    )

                    • 7. Re: Evaluate ("Self")
                      philmodjunk

                      In the first example you could use:

                      Let( [
                      off = $$AutoEnterOff ;
                      id = Name ID ;
                      name = RelatedTable::Name ;

                      thisField = Self ;

                      result = If ( off ; thisField ; name )
                      ];
                      result
                      )

                      and the second:

                      Let( [
                      newDate = table::DateStart ;
                      thisField = Self ;

                      result = Max (newDate ; thisField ) ;
                      ];
                      result
                      )

                       

                      • 8. Re: Evaluate ("Self")
                        DavidJondreau

                        Nope. In both those cases, if I change the field itself, that will cause the calc to trigger again replacing whatever the user entered.

                        One: The user can't change the name at all. If $$AutoEnterOff is not set to True, then any change to the field will cause the calc to trigger replacing the change.

                        Two:The user can never put a value that's less than the value that's in Start Date.

                        I guess I'm not looking for alternatives, I'm asking if anyone

                        -has seen this issue

                        -can explain why it happens

                        -can tell me where to file a bug report

                        • 9. Re: Evaluate ("Self")
                          philmodjunk

                          Yes, but Evaluate ("self") even if allowed, wouldn't change this behavior.

                          I think you'll need to use script triggers to get the functionality that you want here.

                          • 10. Re: Evaluate ("Self")
                            raybaudi

                            "I currently refer to its own name in quotes (Evaluate ("table::field")), but want to change that so I don't have to worry about changing hard coded field names."

                            May be I didn't understand but, why not:

                            Evaluate ( Quote ( table::field ) )

                            • 11. Re: Evaluate ("Self")
                              philmodjunk

                              Hmmm, used this auto enter calculation in place of the second expression:

                              Max ( self ; DateStart )

                              and cleared the "do not replace existing value..." option.

                              If I enter a value in date start, I see the same value appear in date end. If I then edit DateEnd, the entered date reverts to DateStart if if is less than DateStart or it is retained if it is greater than or equal to DateStart.

                              How does that differ from what you want here?

                              • 12. Re: Evaluate ("Self")
                                DavidJondreau

                                Sigh.

                                I don't want the calc to trigger when I'm modifying the field. Using the function Self or the field name itself makes the calc trigger when it is modified. Wrapping it in a Quote() still makes it trigger.

                                "If I enter a value in date start, I see the same value appear in date  end. If I then edit DateEnd, the entered date reverts to DateStart if  if is less than DateStart or it is retained if it is greater than or  equal to DateStart.

                                How does that differ from what you want here?"

                                When you edit DateEnd, I want that value to remain, whether it's greater or lesser than DateStart. If DateStart is edited, then I want the comparison to be made. That's the difference.

                                But I'm not sure what point the point is of discussing my example.

                                It appears the function Self does not evaluate correctly when the literal text is fed into Evaluate().

                                As I said in my earlier post

                                "I guess I'm not looking for alternatives, I'm asking if anyone

                                -has seen this issue

                                -can explain why it happens

                                -can tell me where to file a bug report"

                                • 13. Re: Evaluate ("Self")
                                  philmodjunk

                                  Bug Reports should be made in the Report an Issue section.

                                  Before you make such a report, please consider: If I used

                                  Let ( x = Evaluate ("5 +5")

                                  or

                                  Let ( x = 5 + 5

                                  Either way, x is set to the same value 10.

                                  Likewise, if You could use Let ( x = Evaluate ( "self )  //which you can't do

                                  it would be the same as using Let ( x = self  // which you can do

                                  Discussing your examples is a way to suggest work arounds that you can use right now, and hopefully to help you better understand how these expressions will evaluate.

                                  Going back to my last post. If you check the "Do not replace existing values check box"

                                  Entering a value in date start results in this value being automatically copied to Date end, but now, if I edit the date in Date end to a different date, the value is retained. Perhaps I still am misunderstanding what you want here, but that looks to me like it would do what you want in far simpler fashion.

                                  • 14. Re: Evaluate ("Self")
                                    DavidJondreau

                                    "Likewise, if You could use Let ( x = Evaluate ( "self )  //which you can't do

                                    it would be the same as using Let ( x = self  // which you can do"

                                    It's not the same. It's similar, but one causes the field to re-evaluate when the field itself is changed and the other doesn't. As you note, one works, and the other doesn't.

                                    My understanding is clear: the function Evaluate () does not work as documented. I'm don't understand why you don't think that's a bug.

                                    ___

                                    From you last post, you are misunderstanding. I'm sorry you're having a hard time getting this:

                                    I want the calc DateEnd to (potentially) change when DateStart is modified. Checking Do  Not Replace prevents this.
                                    I want to be able to edit DateEnd and have the value I put in stick.  Using a naked Self prevents this.

                                    ____

                                    I've already presented my thoughts for workarounds and why they're unsatisfactory. I've also presented another example that you haven't given suggested a workaround for. But, again, I don't want workarounds, I want answers to three very specific questions. And a pony.

                                    1 2 Previous Next