Repeatable requirement validation alerts

Use this to alert the user if a field in a repeatable section does not have a value.

This example will populate the warning box that is typically displayed when attempting to save a record that has empty required fields with more information about which child record has no value in a field when saving the root level record.

$repetable_section should be replaced with the repeatable section being used and repeatable_field should be replaced with the field that you wish to have the alert work for. The text (‘Repeatable Section record’ and ‘ is missing a repeatable field value.’) in the INVALID('Repeatable Section' + index + ' is missing a repeatable field value.') should also be replaced with the section’s name and the field with the requirement.

ON('validate-record', function (event) {
 var conditions = REPEATABLEVALUES($repetable_section, 'repeatable_field');
  for (var i = 0; i < conditions.length; i++) {
    if (conditions[i] === undefined) {
      var index = i+1;
      INVALID('Repeatable Section record' + index + ' is missing a repeatable field value.');
    }
  }
})

Note: If the fields are still set as required though the app designer, both the system and the data event alerts will be displayed when you save the root level record. Removing the system field requirements will result in a cleaner alert message when saving the root level record, but will also remove the alert presented when saving the child record in the repeatable section.