cancel
Showing results for 
Search instead for 
Did you mean: 
billr
Nintex Newbie

Dynamically add Options to Select

Jump to solution

Overview:

We use and external data lookup and in turn populate form elements.

One of the pieces retrieved is added to a Select element on the form. All of that is working just fine.

An inspection of the HTML shows the items have been added, however, when the form is submitted a SharePoint error is thrown and the form submission fails.

If a static Option (not added by jQuery) in the Select is chosen the form submits just fine.

Details:

  1. We are using a REST call via jQuery and retrieving JSON
  2. JSON is well formed
  3. We then loop over the options and append them to the Select

Example:

<select name="ctl00$SPWebPartManager1$g_f3cb44cb_28a3_493f_8344_c409b53f4e86$ctl00$ListForm2$formFiller$FormView$ctl18$f1b815d2_ac95_4bc5_8e56_236efde79a32"
 class="nf-choice-select nf-associated-control"    id="ctl00_SPWebPartManager1_g_f3cb44cb_28a3_493f_8344_c409b53f4e86_ctl00_ListForm2_formFiller_FormView_ctl18_f1b815d2_ac95_4bc5_8e56_236efde79a32"
    formcontrolid="9850bce4-6706-4791-9fbf-837cd4b35932" data-use-attribute-as-value="data-nfChoiceValue">
 <option value="1">Other</option>
 <option value="51363800002">Card - 51363800002</option>
 <option value="20008">Book - 20008</option>
 <option value="10006">Mortgage - Long term - 10006</option>
 <option value="10006">Mortgage - Short term - 10006</option>
</select>

Other is added via the Nintex Form Control
All other options are added via jQuery

Thoughts?

Tags (3)
0 Kudos
Reply
4 Replies
billr
Nintex Newbie

Re: Dynamically add Options to Select

Jump to solution

So, did some experimenting.

We added a Choice Control to the form and did not bind it to the List.

We then added a Textbox and wrote some client side JavaScript to populate the Textbox on change of the Choice Control (Select).

Same outcome. When we submit the form we get a SharePoint error with a correlation ID. Nothing note worthy in the logs.

Since the additional Options are being added post page load, do we need to bind them to an object, say a Nintex object?

Validation doesn't throw an error.

It's like the Browser knows the choices are there and legitimate, but the form submission mechanism does not.

Ramblings done

Thanks in advance

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamically add Options to Select

Jump to solution
Reply
billr
Nintex Newbie

Re: Dynamically add Options to Select

Jump to solution

I marked your reply as Answered, Thanks!, but would like to show how I simplified the solution you pointed to. Simplified in my own way of thinking anyway

    NWF$('#' + member_accounts).change(function (e) {
        NWF$('#' + member_account_to_use).val( NWF$('#' + member_accounts + ' option:selected').val() );
    });

    NWF$('input[value="Save"]').click(function () {
        // alert('Save?');
        NWF$('#' + member_accounts).prop('disabled', true);
    });

First binding places the selected value from a specific dropdown into a textbox that is connected to the SharePoint list.

Second binding then disables the dropdown prior to submission to the SharePoint list.

In the thread you pointed me to, he disables all dropdowns. Not an option for me and that is why I only disabled a named instance of a dropdown.

It works. I am not a fan. At all.

Seems there should be a mechanism to tell Nintex that there are new (legitimate) options in the select. My best guess is it is in the Validation step that is triggered by the submit button.

What the heck  It works!

Thank you Marian!!

Reply
billr
Nintex Newbie

Re: Dynamically add Options to Select

Jump to solution

Follow up

Be sure to add a click handler for the Cancel button too Smiley Happy

0 Kudos
Reply