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
  • 85 views
  • Translate

HeidiV
Forum|alt.badge.img+2

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

 

Did this topic help you find an answer to your question?

2 replies

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

 

This functionality is not possible in Responsive Forms unfortunately.

Translate

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • 834 replies
  • 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

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings