1
0
-1

I have a datafield that returns one of two strings or else false. The calculation is mainly based on radio buttons, but both of the calcs for the strings require a checkbox to be true. The checkbox is on page 1, radio buttons on page 2, i've put the datafield in the Logic block outside of the content (was on page 2, didn't make a difference).

I then base a fair bit of logic on the strings returned by the datafield, including collaboration routing.

It all works perfectly, until I untick that checkbox and the datafield value does not appear to be recalculated? I can change the radio button values and that works fine, just not that checkbox.

It is driving me bonkers! Anyone any idea why this may be happening and what can be done about it?



    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      Hi Lin,

      I added 2 pages onto a blank form, added the checkbox under page 1, and the 6 radio buttons, data field,and a text box to verify the output, and it updated the calculation as expected to false when the checkbox is unticked. Sounds like an issue with another component not updating its data from the datafield. However I do seem some logic errors in this script though, such as redundant logic of the checkbox === true inside a statement that says it already is true, and superseded logic of bb or bc == 'No' in the else statement as they are already validated in the if statement as 'Vehicle'. 

      Regards,

      Joel


      var v;
      if (data.ad === true ) {
      	if ( data.ab == 'Yes' && (data.bb == 'Yes' || data.bc == 'Yes') && (data.dd == 'Yes'|| data.du == 'Yes') && data.de == 'Yes') {
            v = 'Vehicle';
      	} 
      	else if (data.ad === true && (data.ab == 'No' || data.bb == 'No' || data.bc == 'No' || (data.dd == 'No' && data.du == 'No') || data.de == 'No')) {
            v = 'FailVehicle';
      	}
      	else {
            v = false;
      	}
      }
      else {
        v = false;
      }
      
      return v;
        CommentAdd your comment...
      1.  
        1
        0
        -1

        This is my calc rule on the data field:

        if (ad === true) {
        	if ( ab == 'Yes' && (bb == 'Yes' || bc == 'Yes') && (dd == 'Yes'|| du == 'Yes') && de == 'Yes') {
        	  v = 'Vehicle';
        	} 
        	else if (ad === true && (ab == 'No' || bb == 'No' || bc == 'No' || (dd == 'No' && du == 'No') || de == 'No')) {
        	  v = 'FailVehicle';
        	}
        	else {
        	  v = false;
        	}
        }
        else {
          v = false;
        }
        
        return v;

        With ad being the checkbox and the other variables are all radio buttons. We tried a few different ways to write this script, but either way, the 'else return false' should cover the event of the checkbox being unticked.

        I know it's not an elegant strategy, but the complex nature of the form made this the best way to ensure that elements show and hide again when selections are changed. Which works flawlessly for the radio buttons, just not for that checkbox.

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Hi Lin,

          Sounds like a logic issue to me. Have you put a clause on the if checkbox == false? If all of your logic is inside the condition of the checkbox being true, then it will not change to anything when the checkbox is false.

          Regards,

          Joel

            CommentAdd your comment...