6 Replies Latest reply on Apr 12, 2017 10:39 AM by danshockley

    Calculated Value with 'if' statement


      I am trying to make a field go to a specific character, only if another field exceeds "1"- to idiot proof my app.


      If ( Indoor Unit WC > 1 ; Indoor Unit WC ="F" )


      When the value of "Indoor Unit WC" is greater than 1 (and modified to be even greater), the field with this calculation does not change to "F" as expected. (I tried both Calculation(with override) and validation, incase I was mixing them up).

        • 1. Re: Calculated Value with 'if' statement

          To change the value of a field, you use the SET FIELD script step.


          And are you sure you want to change the value from a numeric value (>1) to an "F"?  Without knowing more about what you're doing, I think a second field would be better for storing that "F" value -- so you don't lose data in the original field.




          HOPE THIS HELPS.

          • 2. Re: Calculated Value with 'if' statement

            And that second field could be defined as a calculation field with:


            If ( Indoor Unit WC > 1 ; "F"  ; Indoor Unit WC )


            But if you really want this to be all in one field:


            If ( getasNumber ( self ) > 1 ; "F"  ; Self )


            Define that as an auto-enter calculation with the "do not replace..." check box cleared.

            • 3. Re: Calculated Value with 'if' statement

              I am trying to use the field's calculation option so I do not need any scripts and it will automatically update on its own. "Indoor Unit WC" is a separate field from this current one (the "status" field of "Undoor Unit WC").


              And neither of those calculation formulas worked

              • 4. Re: Calculated Value with 'if' statement

                That's not what you posted in your original post. The only field identified was "Indoor Unit WC" in a calculation that referred to this field and then (incorrectly) tried to change the value of the same field. "Undoor Unit WC" was not shown anywhere until this last reply by you.


                If I read your last post correctly, you just need this calculation field for Indoor Unit WC:


                If ( Undoor Unit WC > 1 ; "F"  ; Undoor Unit WC )

                • 5. Re: Calculated Value with 'if' statement

                  it is supposed to be "Indoor", spelling mistake :/ (I am all over the place being rushed to completed several things at once here)


                  I got it working now, but it was by pure change of randomly trying to put "F" in both statement fields, and then replacing one with "" till it worked. The description of how the calculation version of If statements was poor in documentation and I was unable to decipher how it even worked.

                  • 6. Re: Calculated Value with 'if' statement

                    I think "Undoor" was a typo, and he meant "Status of Indoor Unit WC" is the calculation field.

                    Also, it isn't clear to me whether tleitzkewants the "Status" field to be an auto-enter (that could then be edited after it defaults to getting the "F"), or a straight Calculation field.

                    For either, the question is what the result should be when "Indoor Unit WC" is NOT greater than 1: should the Status be blank? Something else? Should it keep whatever it had before (thus, auto-enter)?