Have an idea?

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

Fix values without asking that question

Dear Sir, i want to fix value of the question without asking it from respondent.
so how can i fix value in a Question without punching
asked Sep 8, 2015 by Nouman Saeed Bronze (515 points)

1 Answer

+1 vote
You can use the SetValue SSI Script function.

It takes the form ...

SetValue(QuestionName,Value)

e.g. SetValue(Q1,5) will set Q1 as a value of 5.

This function can update questions, merged fields or pass-in fields.

Very handy.
answered Sep 8, 2015 by Paul Moon Platinum (55,975 points)
Dear Paul,could you plz elborate it plz
If I had a question that I did not want to ask (say Q1) but needed to update it later in the survey, I could always skip Q1 and then insert this script below into the footer of a question after Q1 (say at Q2 or later) ...
[%SetValue(Q1,5)%]

As mentioned above, this would set Q1=5.

I would then test the survey and check the Q1 variable had updated to a 5 to confirm the script actually worked.

Note - if conditions are required on the variable update, Perl script would be required. See example ...
[%Begin Unverified Perl 

 if(VALUE("QA") eq "T1") 
  {  
   SETVALUE("Q5",1);  
  }
 
 elsif(VALUE("QA") eq "T2") 
  {  
   SETVALUE("Q5",2);  
  }
 
 elsif(VALUE("QA") eq "T3") 
  {  
   SETVALUE("Q5",3);  
  }

End Unverified%]
Thank you paul
...