shk21
Nintex Newbie

Repeating section drop down list options

Jump to solution

Hi all,

I have a drop down list in a repeating section, where the option values are populated dynamically using JavaScript below.

NWF$("#" + accounts).append(options);

where accounts is the drop down list name and options are values that is populated as choices.

This works fine and the drop down list in the repeating section gets populated.

However, when I add a new row in the repeating section, drop down list in the new row does not have these choices.

Is there a way I can maintain the choices throughout the entire repeating section?

If not, how can I access the new row to populate the same choices?

thanks.

Reply
41 Replies
cju
Automation Master

Re: Repeating section drop down list options

Jump to solution

Take a look at this article :

JavaScript events in Nintex Forms

You can execute your method that adds options in the NWF.FormFiller.Events.RegisterRepeaterRowAdded function.

Hope this helps

0 Kudos
Reply
cju
Automation Master

Re: Repeating section drop down list options

Jump to solution

Also as it is a repeating section, you should add css class to your dropdown list control instead of using the ID of the control. You can execute the following to add options to this control each time a row is added :

NWF$(".css-class-of-your-repeating-section .nf-repeater-row:last .css-class-of-your-dropdown-list select").append(options);

As the ID is unique, it will only be available for the control in the first row. If you add a css class in the settings of the control, this class will be added on the control in each row.

Hope this helps

View solution in original post

Reply
shk21
Nintex Newbie

Re: Repeating section drop down list options

Jump to solution

That worked! you are great! thanks a lot. I would never have guessed that command.

Reply
cju
Automation Master

Re: Repeating section drop down list options

Jump to solution

Cool, I'm glad that it helped you !

Reply
shk21
Nintex Newbie

Re: Repeating section drop down list options

Jump to solution

Hi Caroline, I have another question on the repeating section, I tried accessing the selected value of drop down list on the last row using below line but does not seem to work. Do I need to add anything else?  Also, is there a way I can loop through each repeating section rows using javascript? thanks again.

NWF$(".css-class-of-your-repeating-section .nf-repeater-row:last .css-class-of-your-dropdown-list select").val();

0 Kudos
Reply
cju
Automation Master

Re: Repeating section drop down list options

Jump to solution

To access the selected option in the dropdown list on the last row, you can use the following :

NWF$(".css-class-of-your-repeating-section .nf-repeater-row:last .css-class-of-your-dropdown-list select option:selected");

To loop through each row, you can use the following :

NWF$(".css-class-of-your-repeating-section .nf-repeater-row:not(.nf-repeater-row-hidden)").each(function() {

     // Add your code here

     NWF$(this).find(".css-class-of-your-dropdown-list select option:selected");

});

Hope this helps

0 Kudos
Reply
shk21
Nintex Newbie

Re: Repeating section drop down list options

Jump to solution

That worked well, thanks.

0 Kudos
Reply
shk21
Nintex Newbie

Re: Repeating section drop down list options

Jump to solution

Hi Caroline,

The form is working well but when I submit the form, there are problems with dynamically populated repeating section data using JavaScript.

1. When I assign a value to a email column in repeating section using JavaScript like NWF$(".euclass .nf-repeater-row:last .email").val("test"); it works well. However, when I save the form and view the saved XML, email node is empty. If I change the value of this email column before submitting form, then the value comes up in the saved XML.

2. Assigning new options/choice to a drop down list in repeating section works well using the JavaScript, however, then I try to submit the form, SharePoint gives error. I suspect that is because the options/choices dynamically assigned on the form are not in the original options/choices when the drop down list was created. For example, a drop down list column was created with choices "a", "b" and "c". Nintex form assigns new value "d" using NWF$(".css-class-of-your-repeating-section .nf-repeater-row:last .css-class-of-your-dropdown-list select").append("<option value="d">d</option>);   then it throws an error.

Would you have any suggestions on these issues? thanks again.

Sam

0 Kudos
Reply
cju
Automation Master

Re: Repeating section drop down list options

Jump to solution

For your first question, you can try to add the following :

NWF$(".euclass .nf-repeater-row:last .email").val("test");

NWF$(".euclass .nf-repeater-row:last .email").focus();

NWF$(".euclass .nf-repeater-row:last .email").blur();

but I'm not sure if it will work.

For your second question, you cannot add custom drop down options but what you can do is having all the drop down options and in javascript, removing the options that you don't want to be displayed.

For example, your drop down list column was created with options "a", "b", "c" and "d" and then in javascript, you can remove options "a" and "b".

Hope this helps

0 Kudos
Reply