Have an idea?

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

Custom java script not working

Hi,

I am using simple Validation script in attached but it’s not working, can someone help to understand the problem so I can learn and improve next time. The problem is even we give correct response still it shows an error message.

PN:  A5W3 & A5 both have same response type, and I am checking it should match else display an error message.
A5 is asked in Initial part of survey and A5W3 is asked at end of the survey.

if (SSI_GetValue("A5") != SSI_GetValue("A5W3"))
{
strErrorMessage = "Selection don't match Wave 1, please select correct response option.";
}

Please guide what is wrong here?
asked Jan 10, 2019 by Nischay

1 Answer

+1 vote
SSI_GetValue should only be used if you are calling a response that is on that page.  If you are calling on a response from a different page use SSI Script [% %].  So if your Validation script is on the question A5W3 then it should look like this (since you indicated that A5 is on an earlier screen):

if ([%A5%] != SSI_GetValue("A5W3"))
{
strErrorMessage = "Selection don't match Wave 1, please select correct response option.";
}
answered Jan 11, 2019 by Jay Rutherford Gold (37,685 points)
Nice one Jay. I often forget this myself. Appreciate the reminder.
Thanks Jay this explains... I did simily work around by putting [%A5%] in variable and used here. Thanks once again
...