Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Assembling a constructed list

Hello,

I have a multi-select question (Q11UAConsoles) and would like to create a constructed list based off of the responses and use this list in a future question. Basically if they select response option 1 in Q11 they see a list of pieces associated with that console (list member 5 and 6 on my "UAHandpieces" list. I've been messing around with it for awhile and went from getting script errors, to not the write pieces in the list, and now back to script errors. I'm sure it's something simple but I can't figure it out.

The below is for the UAChosen constructed list, with parent list "UAHandpieces" where I have listed the pieces associated with each console.
 
Begin Unverified Perl

if ("Q11UAConsoles"=1)
{ADD("UAHandpieces",5,6);}

if ("Q11UAConsoles"=2)
{ADD("UAHandpieces",3,4);}

if ("Q11UAConsoles"=3)
{ADD("UAHandpieces",1,2);}

if ("Q11UAConsoles"=4)
{ADD("UAHandpieces",11,12);}

if ("Q11UAConsoles"=5)
{ADD("UAHandpieces",13);}

if ("Q11UAConsoles"=6,7)
{ADD("UAHandpieces",7);}

if ("Q11UAConsoles"=8)
{ADD("UAHandpieces",8,9,10);}

End Unverified 
asked Jan 13, 2022 by Rick (310 points)

1 Answer

0 votes
Good start.  The syntax for getting the response to a checkbox variable needs to look like this:

GETVALUE("Q11UAConsoles_1")


To represent "___ or ___," we'll need to use the operator "||" between the two criteria.

Finally, the "ADD" function only accepts zero, one, or two numbers after the name of the list.  If we want to add items 8, 9, and 10 to the list, we can use the last case which tells the code to add all items between one number and the other.

Putting that all together, I think these constructed list instructions will work for you:

Begin Unverified Perl
if (GETVALUE("Q11UAConsoles_1")) {
    ADD("UAHandpieces", 5, 6);
}
if (GETVALUE("Q11UAConsoles_2")) {
    ADD("UAHandpieces", 3, 4);
}
if (GETVALUE("Q11UAConsoles_3")) {
    ADD("UAHandpieces", 1, 2);
}
if (GETVALUE("Q11UAConsoles_4")) {
    ADD("UAHandpieces", 11, 12);
}
if (GETVALUE("Q11UAConsoles_5")) {
    ADD("UAHandpieces", 13);
}
if (GETVALUE("Q11UAConsoles_6") || GETVALUE("Q11UAConsoles_7")) {
    ADD("UAHandpieces", 7);
}
if (GETVALUE("Q11UAConsoles_8")) {
    ADD("UAHandpieces", 8, 10);
}
End Unverified
answered Jan 13, 2022 by Zachary Platinum Sawtooth Software, Inc. (216,575 points)
Perfect, thanks!
...