Start a conversation

Check if all fields are filled in

If you want to check whether certain fields are filled in, you can use the template below. In this template, there are 2 fields: 

Variable name Field label
dem_pat_gender Gender
dem_pat_yob Year of Birth


Replace the labels and variable names in the template with your own. 

'##allowempty##';
var req_labels = ["Gender", "Year of Birth"];
var req_fields = ["{dem_pat_gender}", "{dem_pat_yob}"];
var incomplete = false;
var missingVars = "";
req_fields.forEach(checkCompleteness);
if(incomplete === true){
    "Fields are missing: " + missingVars;
}else{
   "Yes";
} 
function checkCompleteness(value, index, array) {
  console.log(value);
  if(value ==  "'NA'" ){ 
      incomplete = true;
      missingVars  += req_labels[index];
      missingVars  += ", ";
  }
}

If not all fields are filled in, the calculation will show "Fields are missing: ", followed by the field labels of the fields that are empty. If all fields are filled in, the calculation will have the value "Yes". You can choose to add a data validation message if the calculation field value is not equal to "Yes".

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Castor Support Team

  2. Posted
  3. Updated