Question T7101
Visible to All Users

Is it possible to have survey triggers change a survey property?

created 4 years ago (modified 4 years ago)

I added a custom property in my creator called "score threshold" (also made custom properties called "score" for questions & itemvalues) which is a minimum score a user needs to reach if we want to send him to a specific page on the survey ending.

I also want to use triggers, to check if at the end of the survey, any of the questions value equals a specific choice, and if so either change the threshold to 0 (so that when we compare the total score to the threshold we will send him to the specific page, even if the score is lower than the original threshold), or set a boolean variable we can check on the survey side when onComplete is called.

Also is there any way to set a trigger to check all questions if any of them have a specific value? i.e. all my questions are matrix/radiogroup questions with the same 4 choices and I want to check for a specific choice on any of them.

Answers approved by surveyjs Support

created 4 years ago

Hello Haim,
Yes, you can do it. You can use run expression trigger and execute a custom function on it.
Here is the closest example.
Let us know if you need more help on this.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (3)

      You can add a custom property into question. If you check the same value, then it can be a boolean property, that this question need to be checked. You can add a value type property if you need to check a particular question to a particular value. If you are looking for all questions, then you can better do this check onComplete event and not in calculated value.
      In short, for your case, I do not see any reason to use the calculated value. You can have the following code onComplete event.

      JavaScript
      var questions = survey.getAllQuestions(); var hasValue = false; for(var i = 0; i < questions.length; i ++) { if(questions[i],value == "Almost every day") hasValue = true; } if(hasValue) { //do your stuff. }

      Thank you,
      Andrew
      SurveyJS Team

        Thanks, I prefer my method because each survey creator can make is how calculated value and the survey can test it, regardless of the surveys choices

          Got it.

          Thank you,
          Andrew
          SurveyJS Team