Have an idea?

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

Removing an option from a predefined list based on a pass in field

I have 1 pass in fields that I'm using to segment the data called SID. Using this variable i have the quota setup.

For eg, my qualification logic is SID=1211, SID= 1212....etc.

Q1: For a question in the survey I want to remove one of the options in a predefined list depending on this SIDs.

Q2: Depending on the SID, I wish to change the text of the question, ive been trying the code below, not sure why isnt it working?

[% Begin Unverified Perl
if    (GETVALUE("SID")    ==    1211 OR GETVALUE("SID")    ==    1212)
    {
        return "This is new";
    }
        else
    {
        return "This is old";
    }
     
End Unverified %]

This would be of great help. Thanks!!
asked May 19, 2021 by Karuna Tandon (300 points)

1 Answer

0 votes
In your perl script replace OR with ||

That should do the trick.
answered May 19, 2021 by Jay Rutherford Platinum (50,145 points)
Thanks, it worked.
I do have another question, I have 1 pass in field that I'm using to segment the data called SID. Using this variable i have the quota setup.

For eg, my qualification logic is SID=1211, SID= 1212....etc.

For a question in the survey I want to remove one of the options in a predefined list depending on this SIDs.
I was trying to use this code to do this, but couldn't get the results. Can we write the script for constructed lists? cause its shows an error for { and %

Add(Q3List)
[% Begin Unverified Perl
#Condition for displayed text
if    (GETVALUE("SID")    ==    1211)
    {
        REMOVE("Q3List",6);
    }
        else
    {
        REMOVE("Q3List",5);
    }
     
End Unverified %]
You are very close.  In list construction with Perl you do not need [% or %].  So it should be:

Add(Q3List)
Begin Unverified Perl
#Condition for displayed text
if    (GETVALUE("SID")    ==    1211)
    {
        REMOVE("Q3List",6);
    }
        else
    {
        REMOVE("Q3List",5);
    }
     
End Unverified
This worked!! Thankyou soo much!
You're quite welcome.  Glad you were able to sort it out.
...