I have a multi select choice box that is populated by semi colon separated values in one of the items column. So on form load the choice control displays the values that exist in that column. This works fine, but what I'd like to do is get these values all selected by default when the form loads, so if a user doesn't want an item selected they have to click on the choice to deselect it rather than having to select all the options other than the one they don't want.
I have hoped that perhaps setting the Default Value to the item column, Nintex might automagically select the values for me, but no.
NWF$('#' + SelectedProductCodes).prop('selected', true);
but this doesn't seem to do anything.
Solved! Go to Solution.
Thanks for the response.
I'll try this in a bit, at the moment I'm on another issue, which you've answered for other people, but I can't quite get to work.
I have a SQL Request control rendered as Multi select checkboxes. I'm trying to write the selected values of the control into a text field and then clear the selected check boxes in the multi select. I've got the code to write the values into the text box, but I can't clear the check boxes. Should this behave the same way as a normal choice control do you think?
I've tried this
Any suggestions much appreciated.
I do not have at hand a system where I could check how SQL Request control is rendered, just blindly what does following statement return? does it equal to number of control's options?
NWF$('#' + selProductCodes + ' input:checkbox').length
if it returns zero, try
NWF$('#' + selProductCodes).length
if this doesn't bring you on track, are you able to copy and post DOM model (HTML markup) of SQL Request control from developer console?
I may try to look on it.
Our first effort returned 0 but the second returned 1, however, I had multiple options selected when it returned 1 so not sure if this is correct or not.
var choices = (NWF$('#' + selProductCodes).val());
This successfully retrieves all the values selected from the control, so we're obviously accessing the control ok, just not able to reset the control to deselect all.
Just to explain I am using the control as a search results field, it returns results based on a search term entered in a text box, executing a stored procedure that performs a free text search of a product file.
Just below there is a button that users click to commit the selected items into a text box so they can then perform another search and when they click the button again the new selections will be added to the text box as well. So I need to clear down the selected items from the search results to avoid the users adding the same products twice. The value that triggers the search is actually a calculated control as is concatenates a code based on the dropdown they select at the top of the form, with their search term, but only when the search term is longer than 3 characters. So an alternative route I guess is to clear down the search box rather than the search results checkbox? Ignore that, I tried it and it seems programmatically clearing the search box won't work, it seems that you have to manually tab or click out of the search box to trigger the stored procedure to execute. So I will need to clear the search results or the checked items.
Having heard the scenario, do you think I'm approaching this correctly or are there alternative approaches you'd suggest?
it should have returned number of checkboxes within the control (regardless of whether they are selected or not).
but since SQL request is executed dynamically it's important when you issued the command - you should execute it after the control was already populated.
I tried it and it seems programmatically clearing the search box won't work, it seems that you have to manually tab or click out of the search box
after you clear the search box value/content, make a following call, it should invoke recalculation of dependent formulas (if that your restriction of at least 3 characters will not block it)
NWF$('#' + jsvarSearchBox).focusout();