Compulsory Selection in Multi Select

  • 1
  • 2
  • Question
  • Updated 1 year ago
  • In Progress
I have a multi select field (holding State names) which is a required field when creating a new required.  However, due to organisational requirements, we have to ensure that in some cases, users select two states. Largely this is because our entire business is configured so that one large and small state is looked after by a team.

Is there any way that I could ensure that users always select correct second state?   
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb

Posted 1 year ago

  • 1
  • 2
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
How do you define what is the second state?
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Thanks.  We have 5 states.  So we have a combination such as:

WA
QLD
NSW/ACT
SA/NT
VIC/TAS
  
Bottom three should always be in the combination shown. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
Use IOL with this code:

$("#_fid_6").bind("multiselectclose", function(event, ui){
  var selections = $("#_fid_6").multiselect("getChecked");
  if (selections.length < 2) {
    $("#_fid_6").multiselect("open");
  }
});
If _fid_6 is a multi-select field then the popup selection menu will reopen if less than two selections are made. This should be enough of annoyance that your users will conform. As to picking one large and one small state you would have to code that logic to suit your own needs.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,486 Points 50k badge 2x thumb
Arshad,

If you always want certain states selected together, why not just make the choices so that the choice only includes the double state, and not allow a drop down choice of them individually.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Thanks Dan. Is there a very simple step by step instructions on setting up IOL? 

Mark I will take this up with you off line.  
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
The instructions for setting up IOL are in the Notes field of every record in this application. I added the code in my prior answer here:

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=585
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Thank you so much. Good instructions.  One clarification though. Do I need to add the formula field only once in the table and this could work with different modules.  I seem to have two similar fields with different names but addressing different issues.   
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Having some issue. I created the .JS file. I already have the required variables.  I also created a text field with the following code: 

[iol] & "MultiSelect.js" & [/iol]

But when I am saving a new record, it does not fire the error. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
Debug with console.log() statements in your code.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Thanks. Where do you place it? 

$("#_fid_110").bind("multiselectclose", function(event, ui){  var selections = $("#_fid_110").multiselect("getChecked");
  if (selections.length < 2) {
    $("#_fid_110").multiselect("open");
  }
});