Default values for advanced multi-select using cases as options


(Mazen AlAli) #1

Hi guys

So, i’m sure a lot of use are familiar with using cases as multiple-select options.

Here’s my predicament. have two case types, let’s call them student and class.

there’s an attribute for classes that is called “enrolled_students”
it’s the result of a multi-select with student cases as options.

this is an easy and straight forward way for me to enroll students into classes.

what i’d like to add to that, is the option to remove students from classes. now, i can easily show up a multi-select for exactly those students that are enrolled - this is how we track attendance to these classes. but what i would like to add to that is a default value where all of those students are checked “true”.

Any idea how i can default such a multi-select to have all the values already selected? The idea is that the user would then uncheck the student that is no longer supposed to attend.

I’m sure there are a ton of other ways to go about this.

Any help would be great

Thanks

Mazz


(Cody Stahl) #2

Hi Mazz,

Great question!

When you save a multi-select question to a case property, you’re actually storing a space-separated list of the values configured in the “Value Field” of your Lookup Table Data. This means that you most likely have a space-separated list of @case_ids saved as enrolled_students.

Assuming that the multi-select question for which you want to set the default has the SAME “Value Field” configured, you can simply load #case/enrolled_students into the default field, and it will automatically check the box for each case that is in enrolled_students! The user can then add or remove students as they need to.

Hope this helps!
-Cody


(Mazen AlAli) #3

that does sound like a nice workaround if i can have a pre-made multi-select.
I realize that the stored property is essentially space separated values, but how can a build a value-value or value-anything pair in that property?

here’s the problem i’m trying to work around:
A: regular multi-selects can have a default value, if you put a key value from the possible options in that select.
B: advanced multi-select with looking up cases as selection options, require a query that returns a value-attribute pair.
C: i’m using option B to store the property against the case with the space separated key value list.
Objective: I’d like to have a follow up form that shows the options stored through option B, to not only show those value-attribute pair, but to have the selection pre-made to be checked against all of those options.
Why? Because i’d like to give the simplest possible way to remove single values from that property if needed, without having to select all the ones already there except the one you want to remove. The problem is that i don’t already have a pre-made multi-select with known values. the values being stored in this property are case id’s.

makes sense?


(Mazen AlAli) #4

Also, i am able to reproduce a multi-select with those cases, i just can’t figure out how to make them pre-selected


(Mazen AlAli) #5

Oh God…

I tried just adding enrolled_students as a default value, and it worked! they’re all pre-selected…

i guess i must have done something wrong when i was trying this earlier. maybe i didn’t save the property correctly