4 Replies Latest reply on Jun 4, 2015 10:09 AM by tdeppen

    Case Statement Not working

    tdeppen

      Title

      Case Statement Not working

      Post

      Trying to get final cost to auto populate once a completed date is entered into an order. First look at quoted price field, if that is empty use the automatic cost. This is what I am using, but only the quoted price works at this point.

      Case ( not IsEmpty ( Date finished ) ; GetAsNumber ( Quoted Price ) ; 
       IsEmpty ( Quoted Price ) AND not IsEmpty ( Date finished ) ; GetAsNumber ( JOB COSTNEW ) )

        • 1. Re: Case Statement Not working
          tdeppen

          Never-mind....I just got it to work, I flipped flopped to two lines and it seems to work:

          Case ( IsEmpty ( Quoted Price ) and not IsEmpty ( Date finished ) ; GetAsNumber ( JOB COSTNEW ) ; 
          not IsEmpty ( Date finished ) ; GetAsNumber ( Quoted Price ) )

          Since I am here, does this look good? I am somewhat new at this, so I might as well double check my logic. 

          • 2. Re: Case Statement Not working
            SteveMartino

            Sort of.  What happens if Date finished is empty?  What happens if there is nothing in the Quoted price? If those things never happens, then:

            Case (

            IsEmpty ( Quoted Price ) and not IsEmpty ( Date finished ) ; GetAsNumber ( JOB COSTNEW ) ; 
            GetAsNumber ( Quoted Price )

            )

            It always helps to test for all scenarios, specifically make sure fields that should never be blank are validated when entering new records so the calculations don't fail or give wrong results.

             

            • 3. Re: Case Statement Not working
              philmodjunk

              Don't see any reason to use the GetAsNumber function here. It does no harm but complicates the expression.

              • 4. Re: Case Statement Not working
                tdeppen

                Thank you for the tip. I will remove the function keeping it as clean and simple as possible.