Have an idea?

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

Need help piping open end answers into row-list

Actually I pipe the answer of three open end questions in a predefined grid row list (Brands):

 
Brand1
[%Q2a%]
[%Q2b%]
[%Q2c%]


Unfortunately that's not good enough, because we don't want do add empty rows to the grid.

Who can me help to solve it?  My approach was a constructed list (BrandsConstructed), but it doesn't work :
 
ADD(Brands,1)
Begin Unverified Perl
if (length("Q2a")!=0)
{
 ADD("Brands",2);
}
if (length("Q2b")!=0)
{
 ADD("Brands",3);
}
if (length("Q2c")!=0)
{
 ADD("Brands",4);
}
End Unverified


I appreciate your comments.

Thanks in advance!
Alex
asked Nov 11, 2016 by Alex C

1 Answer

+1 vote
Your code is really close.  This code:

length("Q2a")


will always return 3, because that's the length of the string "Q2a."  You need to use GETVALUE to get the value stored for question Q2a.  Here's the code with this change made:

Add(Brands, 1)
Begin Unverified Perl
if (length(GETVALUE('Q2a')) != 0) {
    ADD('Brands', 2);
}
if (length(GETVALUE('Q2b')) != 0) {
    ADD('Brands', 3);
}
if (length(GETVALUE('Q2c')) != 0) {
    ADD('Brands', 4);
}
End Unverified
answered Nov 11, 2016 by Zachary Platinum Sawtooth Software, Inc. (86,625 points)
Hey, now it works!  
Thank you very much Zachary!!!
...