Question T15024
Visible to All Users

defaultValueExpression for comment question

created a year ago

Hello,
When I set a multiple lines string in the defaultValueExpression property of a comment question it doesn't work.
Thanks for help.

Comments (2)

    Hello Mohamed,
    Would you please share an example of your defaultValueExpression string? If possible, share a full Comment question definition.

      {
      "type": "comment",
      "name": "question1",
      "defaultValueExpression": "aaaaaaaaaaaa\nbbbbbbbbbb"
      }

      Answers approved by surveyjs Support

      created a year ago

      Hello Mohamed,
      Thank you for the update. As you use the defaultValueExpression property, you are expected to pass an expression rather than a string literal. So, you can fix your Comment question definition by enclosing a string within a single quotes.

      JSON
      { elements: [ { type: "comment", name: "question1", defaultValueExpression: "'aaaaaaaaaaaa\nbbbbbbbbbb'" } ], showQuestionNumbers: false }

      View CodeSandbox

      A survey appears as follows:
      Clipboard-File-1.png

      Please let me know if you have any further questions.

        Comments (1)

          Ah Ok.
          Thanks you Jane :)