Issue T20012
Visible to All Users

Running expression with displayValue is returning false

created 3 months ago

Hi,

I am running below expression on survey,

survey.runExpression(displayValue("Please select the option which describes the circumstan"));

It is giving me result as false even I can see there is value as well as displayValue present for that question.

Clipboard-File-1.png

Am i doing something wrong here?

Thanks,
Ramkumar MOre

Comments (2)

    Hello,
    Would you share a survey JSON definition so that I can test it on my end? Also, please elaborate on your end goal.

    Thanks

      Hi Jane,

      Sharing the entire JSON is quite difficult since it contains some confidentials information.

      What I am trying to achieve here is a summary of all the questions in questionnaire into a question for that I am adding an expression which will collect the responses of the questions.

      For some reasons like I have a need of using displayValue in this function but seems like it is not working & giving me result as false.
      Without displayValue the expression is working fine but it is not showing the displayText of selected value.

      Thanks,
      Ramkumar More

      Answers approved by surveyjs Support

      created 3 months ago (modified 3 months ago)

      Hello Ramkumar,
      Thank you for the clarification. If you wish to programmatically get a question's display value, no need to run the expression function. Please use the question.getDisplayValue() function.

      JavaScript
      const allQuestions = survey.getAllQuestions(true, false, false); allQuestions.forEach(question => { console.log(question.getDisplayValue()); });

      Consider this sample demo: View Plunker.

      Let me know if you have any further questions.

        Show previous comments (5)

          Hello,
          This PR fixes the issue. The fix will be available in the version we will release next week.

          Thank you,
          Andrew
          SurveyJS Team

            Hi Andrew, Is this fix got released to NPM?

              Hello,
              Yes, Please use the latest version. The fix is included into the release.

              Thank you,
              Andrew
              SurveyJS Team