Table: Making Tables Required

Body

When you need to have at least one row filled in a table and you can't use the required button in the properties box.

In order to make this work, you need to have a trigger question preceding it. In this example, the trigger is a Yes or No question.  

This rule also makes any added rows required if the first column is filled, and nulls/un-requires/disables the columns if No is selected for the Trigger.

**the layout of this rule is also applicable to repeater sections. 

//Main rule based on a yes/no trigger question
if (Trigger_Question.value == 'Yes'){
  
  //covers when the green plus sign is clicked to repeat the section
  if (Table_NameRepeat.itemAdded){
    i = Table_NameRepeat.itemIndex;

    ColumnA[i].enabled = true;
    ColumnA[i].required = true;
    ColumnB[i].enabled = true;
    ColumnB[i].required = true;
    ColumnC[i].enabled = true;
    ColumnAC[i].required = true;

  } else {
    
   //covers what already exists (aka: no item added)
    for ( var i=0; i < ColumnA.value.length; i++) {
      ColumnA[i].enabled = true;
      ColumnA[i].required = true;
      ColumnB[i].enabled = true;
      ColumnB[i].required = true;
      ColumnC[i].enabled = true;
      ColumnC[i].required = true;
    }
  }
  
} else { 
  //if Yes is not selected (includes No option & if nothing is selected)
  for (var i=0; i < J6Agent.value.length; i++) {   
    ColumnA[i].enabled = false;
    ColumnA[i].required = false;
    ColumnA[i].value = null;

    ColumnB[i].enabled = false;
    ColumnB[i].required = false;
    ColumnB[i].value = null;
 
    ColumnC[i].enabled = false;
    ColumnC[i].required = false;
    ColumnC[i].value = null;
    
 }
}

Details

Details

Article ID: 51454
Created
Tue 4/3/18 4:22 PM
Modified
Mon 4/16/18 5:08 PM