3 Replies Latest reply on Jul 8, 2019 7:56 PM by fac586

    How to get sum of RadioGroups

    PaoloRicardos

      How to get sum of RadioGroups in DA

       

      I have 3 RadioGroups, i would like to get the sum of Radios in other Item "Results", I made a DA with PL/SQL block that works, but I just get the result only if all 3 radiogroup are select, and if it is possible to do with javascript

       

      1.png2.png

        • 1. Re: How to get sum of RadioGroups
          fac586

          PaoloRicardos wrote:

           

          How to get sum of RadioGroups in DA

           

          I have 3 RadioGroups, i would like to get the sum of Radios in other Item "Results", I made a DA with PL/SQL block that works, but I just get the result only if all 3 radiogroup are select

          This happens due to the handling of NULL values in Oracle. NULL values are neither equal nor inequal to any other value, so none of the conditions in lines 11-13 are true. If any value in a numerical expression is NULL then so is the entire result, which is what occurs with the total calculated in line 17.

           

          The required approach is to convert the NULL values to 0 using the COALESCE or NVL functions in a PL/SQL Expression Set Value DA:

           

          coalesce(to_number(:p4_radio1), 0) + coalesce(to_number(:p4_radio2), 0) + coalesce(to_number(:p4_radio3), 0)

          and if it is possible to do with javascript

          Assuming the values are integers, the equivalent JavaScript expression using the ternary operator is

           

          parseInt($v('P4_RADIO1') ? $v('P4_RADIO1') : 0), 10) + parseInt($v('P4_RADIO2') ? $v('P4_RADIO2') : 0), 10) + parseInt($v('P4_RADIO3') ? $v('P4_RADIO3') : 0), 10)

          1 person found this helpful
          • 2. Re: How to get sum of RadioGroups
            PaoloRicardos

            Thanks the PL/SQL worked, but that one in Java doesn’t work, and I can’t figure out what is wrong.

            • 3. Re: How to get sum of RadioGroups
              fac586

              PaoloRicardos wrote:

               

              Thanks the PL/SQL worked, but that one in Java doesn’t work, and I can’t figure out what is wrong.

              I can. JavaScript is case sensitive. Make the item names uppercase.