Refresh the Repeated Section when dropdown value has changed

  • 19 March 2019
  • 6 replies
  • 5 views

Badge +11

Hello

 

I have setup a Rule within the repeated section to disable the field if the [currentRowNumber] is bigger than the ItemNumber which works fine but when the dropdown [ItemNumber] is changed then the rule does not get refresh/reactivated.

 

For example: I set the ItemNumber to 2 and then add 3 new rows within repeated section; in this case the 3rd row will be disabled (at least the intput field). However, when I update the ItemNumber to 1 then the row 2 and 3 are still editable ... unless I remove the 3rd row - which then triggers 2nd row to be disabled.

 

My thoughts is to have kind of a .onChange mechanisem to refresh the rule when ItemNumber has changed.

 

Scenario:

 

[ItemNumber]: 2 (dropdown)

[currentRowNumber]: currentRowNumber(ItemDescription)

[RepeatedSection]: [ItemDescription] field has a rule (greaterThan(,[currentRowNumber).[ItemNumber]) to disable the field.

 

It works when ItemNumber is selected a higher number and then you keep adding the additional rows. But when you have 4 rows already and then change the ItemNumber to 2 > then the repeated section does not get refreshed and therefore ALL the rows are still available. Whereas ideally it should disable the bottom 2 fields.

 

Is this possible?

 

A simple test as following works only to clear the text within the field.

Is there a way to say "update, refresh" the field.... instead?

 

NWF$(document).ready(function(){  
var obj = NWF$("#" +Items);  
obj.change(function(){ 
NWF$("#" + ItemDescription).val(''); 
});
});

6 replies

Badge +11
Can somebody please advise?
Badge +11

Anybody can advise on this topic?

 

The rule applied works but then when the fields / dropdown have been changed... the rule is still applying the validation check even though it does not meet the criteria anymore unless you delete the extra row and add a new row instead.

 

Any ideas?

Badge +12

@bimi82 .....Instead of formatting, use validation rule. I've tested the solution and it's working for me. My approach was:

 

  1. I've added a drop down choice control (ch_DropDownValue) with choices from 1 to 5 
  2. I've added a repeating section and inside it, I've added a calc control to display rep sec row #s (calc_RepSecRowCount) and SLT control
  3. I've added a rule on a SLT control:
    • Validation rule
    • greaterThan(calc_RepSecRowCount, ch_DropDownValue)
    • Message: "Your validation message for users"

For testing:

 

  1. I've selected 3 from DD
  2. I've added 4 rows and tried to save, it gave me validation error and highlighted the 4th row's SLT with red border
  3. I then change the value to 2, it highlighted row 3 & 4 SLT control with red border
  4. You might have to apply validation rule on each and every controls you have in RepSection

 

Formatting rule is not working and it's behaving exactly you mentioned, so maybe you can use the validation rule instead. 

 

Let us know if that works for you.

Badge +11

Hello

 

Not sure if we understand each other :/.
In my repeated section I have three lookup dropdown fields and the idea behind is to avoid a user selecting the same item more than once.

 

If you select same item more than once then say "sorry cant select same item more than once..." otherwise let the validation go through.

 

I have validation like this,

 

nameOfField == {Self} && countRows > 1

However, this throws a validation error for each item selected.

Userlevel 5
Badge +14

Could you post any screenshots in addition to this because I've read it a few times, but still don't really understand what you're trying to accomplish outside of getting some rules to fire on Row Add (an unfortunately known problem with Repeating Sections). 

some questions

How many [Item Number] values are there? 

Does the [Item Number] value always corrispond to the Row Number? Additionally, do you just ALWAYS want the [Item Number] to be connected to the Row Number? 

Say you have a new form with (1) default row. If you click 'Add Row' two times, should the [Item Number] be 1, 2, 3? If you were to delete Row 2, should the values change to 1,2 or would they need to now be 1, 3? 


Badge +12

@bimi82 .....I don't see any mentioning about lookup control in the original post !!!!

Reply