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

Dynamic choices in a Choice list?

I placed a regular (non sharepoint ) choice field in a repeating section.   I would like to make the choices dynamic.   I populated the choices using some jQuery.   What works fine.   But when I go to  save the form, I get a "Something went wrong" error.

I found that if I enter one of the "dynamic" choices into the field's list of choices, I do not get the error.   So it seems the selection needs to preexist in the list of choices so it can be selected.

Am I going down the wrong path?   I do see how you can enter formulas for each choice but it seems to be for each individual choice as opposed to a list of choices.

P.S.   I am trying to use a dropdown list as my choice type.

Tags (1)
0 Kudos
Reply
12 Replies
Automation Master
Automation Master

Re: Dynamic choices in a Choice list?

you will have to probably do something similar like mentioned in this comment https://community.nintex.com/message/34492#34492

ie. to set value of two HTML elements

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamic choices in a Choice list?

What you're encountering in an error where the view-state is invalidated because of the values in the choice controls being manipulated on the client-side.

If you take a look at my last response in this thread, I shared the code used to work-around this problem. It involves calling a function when save is clicked to populate a single-line textbox with your choice-control's value and disabling the choice control in order to persist the data to your list without error.

NCAA bracket in Nintex Form

Good luck!

Reply
stempb
Nintex Newbie

Re: Dynamic choices in a Choice list?

Thanks,  I am having a lot of trouble following that thread.   I am still trying to get used to this forum layout.

Is this the post you mean?   I don't understand how to implement this.  Can you please be more specific in your answer?   I am still getting started in this whole Nintex thing.

Do I just place this in my button's Client Click property?   How do I callit?

.

var dropDowns = {

    // Update a single-line text-box with drop-down's selected value

    populateTextBox: function (labelID, dropdownID) {

        var obj = NWF$('#' + labelID);

        obj.val(NWF$('#' + dropdownID + ' option:selected').text());

    },

    // Disables all choice controls based on CSS class

    disableAll: function () {

        NWF$('.gameSelection').prop('disabled', true);

    }

}

0 Kudos
Reply
stempb
Nintex Newbie

Re: Dynamic choices in a Choice list?

Thanks but I am not seeing how this pertains to my issue.   I am not trying to set a default value and if I am reading the thread right, I am not trying to use a lookup list.

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamic choices in a Choice list?

it looks that from certain forms release (the most probably one when lookup manipulations in on/after-ready events stopped working) some form controls are backed by 2 (or maybe more?) HTML elements, one is for visual presentation and second one to be posted. if you set only one of the two it doesn't work correctly. (it's at least my understanding from my own experience)

just wanted to give you hint to check whether choice control wasn't redesigned similar way.

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamic choices in a Choice list?

Right – You'd want some jQuery on your Save/Submit button's Client click property to perform the two functions above:

Screen Shot 2016-03-17 at 12.37.11 PM.png

You'd disconnect your dropdown from your list column and instead associate it with a textbox that you update with the populateTextBox function. After using jQuery to update this textbox, you then disable the choice controls so your error goes away when the save button is clicked.

0 Kudos
Reply
stempb
Nintex Newbie

Re: Dynamic choices in a Choice list?

I got the disabled part OK.    I am still lost at how the values get to the  text text box.   Can you give an example of how to call this inside the button's onCLick?  The dropdown is in a repeating section.   Do I need a text box in the repeating control too?   How would it know which dropdown to put in which textbox?

P.S.   My choice control is not connected to any sharepoint field other than the main field for the repeating section XML results.

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamic choices in a Choice list?

Do you have a way of knowing what the clientID will be for the choice control in the repeating section? For the above solution to work, you'd need a textbox in each of the repeating sections and be able to access these via CSS class or JS clientID despite being dynamically generated with the repeater.

0 Kudos
Reply
stempb
Nintex Newbie

Re: Dynamic choices in a Choice list?

I do not.    I was hoping you could tell me.

I understand how it could work outside a repeating section.   Just don't know how to get the ID when they are inside the section. I know that NWF.FormFiller.Events.RegisterRepeaterRowAdded   passes an argument.   Don't know if there is a way to get it from there.

0 Kudos
Reply