5 Replies Latest reply on Aug 13, 2012 10:55 AM by philmodjunk

    Case

    Kirk_1

      Title

      Case

      Post

      Im using the case statement below.

      For this example $class1 = 55.

      Because im using 55, this should return the data in Discounts::DCClass55.

      It does not, Why?

      • Set Variable [ $class1; Value:Quote Description::DTClass1 ]
      • Set Variable [ $class2; Value:Quote::QTClass2 ]
      • Set Variable [ $class3; Value:Quote::QTClass3 ]
      • Go to Layout [ “Discounts FAK and Assessorial ” (Customer) ]
      • Go to Field [ Discounts::DCCass50_ ]
      • Set Variable [ $fak1; Value:Case ( Quote::QTClass1 ="50" ; Discounts::DCCass50_ = $fak1 ; Quote::QTClass1 ="55" ; Discounts::DCClass55_ = $fak1 ; Quote::QTClass1 ="60" ; Discounts::DCClass60_ = $fak1 ; Quote::QTClass1 ="65" ; Discounts::DCClass65_ = $fak1 ; Quote::QTClass1 ="70" ; Discounts::DCClass70_ = $fak1 ; Quote::QTClass1 ="77" ; Discounts::DCClass77.5_ = $fak1 ; Quote::QTClass1 ="85" ; Discounts::DCClass85_ = $fak1 ; Quote::QTClass1 ="92" ; Discounts::DCCLass92.5_ = $fak1 ; Quote::QTClass1 ="100" ; Discounts::DCClass100_ = $fak1 ; Quote::QTClass1 ="110" ; Discounts::DCClass110_ = $fak1 ; Quote::QTClass1 ="125" ; Discounts::DCClass125_ = $fak1 ; Quote::QTClass1 ="150" ; Discounts::DCClass150_ = $fak1 ; Quote::QTClass1 ="175" ; Discounts::DCClass175_ = $fak1 ; Quote::QTClass1 ="200" ; Discounts::DCClass200_ = $fak1 ; Quote::QTClass1 ="225" ; Discounts::DCClass225_ = $fak1 ; Quote::QTClass1 ="250" ; Discounts::DCClass250_ = $fak1 ; Quote::QTClass1 ="300" ; Discounts::DCClass300_ = $fak1 ; Quote::QTClass1 ="400" ; Discounts::DCClass400_ = $fak1 ; Quote::QTClass1 ="500" ; Discounts::DCClass500_ = $fak1 ; ) ]

        • 1. Re: Case
          Kirk_1

          I see one thing i did, its not from the same table.

          • 2. Re: Case
            Kirk_1

            I changed it to this:

            In the degubber's data viewer, it shows $class1 as 55

             

            • Set Variable [ $class1; Value:Quote Description::DTClass1 ]
            • Set Variable [ $class2; Value:Quote::QTClass2 ]
            • Set Variable [ $class3; Value:Quote::QTClass3 ]
            • Go to Layout [ “Discounts FAK and Assessorial ” (Customer) ]
            • Go to Field [ Discounts::DCCass50_ ]
            • Set Variable [ $fak1; Value:Case ( Quote Description::DTClass1 ="50" ; Discounts::DCCass50_ = $fak1 ; Quote Description::DTClass1 ="55" ; Discounts::DCClass55_ = $fak1 ; Quote Description::DTClass1 ="60" ; Discounts::DCClass60_ = $fak1 ; Quote Description::DTClass1 ="65" ; Discounts::DCClass65_ = $fak1 ; Quote Description::DTClass1 ="70" ; Discounts::DCClass70_ = $fak1 ; Quote Description::DTClass1 ="77" ; Discounts::DCClass77.5_ = $fak1 ; Quote Description::DTClass1 ="85" ; Discounts::DCClass85_ = $fak1 ; Quote Description::DTClass1 ="92" ; Discounts::DCCLass92.5_ = $fak1 ; Quote Description::DTClass1 ="100" ; Discounts::DCClass100_ = $fak1 ; Quote Description::DTClass1 ="110" ; Discounts::DCClass110_ = $fak1 ; Quote Description::DTClass1 ="125" ; Discounts::DCClass125_ = $fak1 ; Quote Description::DTClass1 ="150" ; Discounts::DCClass150_ = $fak1 ; Quote Description::DTClass1 ="175" ; Discounts::DCClass175_ = $fak1 ; Quote Description::DTClass1 ="200" ; Discounts::DCClass200_ = $fak1 ; Quote Description::DTClass1 ="225" ; Discounts::DCClass225_ = $fak1 ; Quote Description::DTClass1 ="250" ; Discounts::DCClass250_ = $fak1 ; Quote Description::DTClass1 ="300" ; Discounts::DCClass300_ = $fak1 ; Quote Description::DTClass1 ="400" ; Discounts::DCClass400_ = $fak1 ; Quote Description::DTClass1 ="500" ; Discounts::DCClass500_ = $fak1 ; ) ]
            • 3. Re: Case
              Sorbsbuster

              I don't think you have the syntax of a Case Statement correct.  it should read as :

              Case (

              If this value = this condition ; return this value ;

              If not, then if this value = this condition ; return this value ;

              If not, then if this value = this condition ; return this value ;

              If none of those conditions are met ; return this value

              )

               

              ---------------------------

              You seem to have:

              Case (

              If this value = "50"                        ; If this value = $fak1
              Quote Description::DTClass1 ="50" ; Discounts::DCCass50_ = $fak1 ;

              Quote Description::DTClass1 ="55" ; Discounts::DCClass55_ = $fak1 ;

              etc )

               

              So you don't need the variable $fak1 in the Case statement.
              You shouldn't need quotation marks around the numeric values.
              You shouldn't need the Go to Field line.
              The related fields you include in the calculation have to be valid relationships from the Customer Table.

              • 4. Re: Case
                Kirk_1

                That worked

                Ty

                • 5. Re: Case
                  philmodjunk

                  You might also consider using an auto-enter setting to use the value in a field instead of a variable so that your values can be looked up from a table using a relationship based on that field. This enables you to manage both the discount values and the category values used to determine what discounts are looked up in data entry operations instead of having to redesign your case function each time a category value is changed.