Skip to main content
Nintex Community Menu Bar
Question

How to prevent duplicate date selections in repeating table in responsive forms

  • July 13, 2023
  • 2 replies
  • 100 views

HeidiV
Forum|alt.badge.img+4

Does anyone know how to prevent duplicate date selections in repeating table in responsive forms rows?

 

2 replies

Forum|alt.badge.img+2
  • Rookie
  • December 21, 2023

 

This functionality is not possible in Responsive Forms unfortunately.


MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • December 25, 2023

This is a late reply but this can absolutely be done.

 

Using a custom rule with some JS you can check the values of the date controls in sibling repeating section rows, and invalidate any rows with matching dates.

Here is a simple example

 

I’ve made a form with a Repeating Section, and a Date Control:

 

(Important!) I’ve named the Date Control so that I can reference it using this name later in my code:

 

But after my controls are on the form, I create a Validation Rule for the Date Control:

The ‘Validation Message’ is: “You cannot select a date that has already been selected in another row!”

 

The following code can be copy / pasted:

(function(rowIndex, sourceContext) {
var targetControl = NWF$("#" + rowIndex);
var selectedDate = targetControl.val();

var siblingRows = sourceContext.siblings(".nf-repeater-row:not" + "(.nf-repeater-row-hidden)");
var siblingDates = siblingRows.map(function(index, row){
return NWF$(row).find("[data-controlname='control_SomeDate'] .nf-associated-control").val();
}).get();

if (siblingDates.includes(selectedDate)) {
return true;
}

return false;
}(rowIndex, sourceContext))

 

Saving and running the form results in the following:

 

Let me know if this helps