Question T3747
Visible to All Users

Show on Completed method answer in Survey Result Json

created 5 years ago

Hi,
I want to get " Result 2 " Message in my Survey Result Json - To keep track of messages oncomplete survey.

Json:-
{
"completedHtml": "Result 2",
"completedHtmlOnCondition": [
{
"expression": "{question7} = 'Yes'",
"html": "Resut 1"
}
],
"pages": [
{
"name": "page1",
"elements": [
{
"type": "panel",
"name": "panel2",
"elements": [
{
"type": "radiogroup",
"name": "question7",
"title": "Do You have fever? ",
"isRequired": true,
"choices": [
{
"value": "Yes",
"text": "Yes"
},
{
"value": "No",
"text": "No"
}
],
"colCount": 0
}
]
},
{
"type": "radiogroup",
"name": "question1",
"title": "Do You have Cough?",
"isRequired": true,
"choices": [
{
"value": "Yes",
"text": "Yes"
},
{
"value": "No",
"text": "No"
}
],
"colCount": 0
}
]
},
{
"name": "page2",
"elements": [
{
"type": "comment",
"name": "question10",
"visible": false,
"title": "If Yes",
"defaultValue": "Risk 1",
"rows": 5
},
{
"type": "comment",
"name": "question14",
"visible": false,
"title": "If No",
"defaultValue": "Risk 2",
"correctAnswer": "Risk 2"
},
{
"type": "expression",
"name": "question6",
"visible": false,
"title": "Risk",
"expression": "{question7} = Yes",
"commentText": "Other (describe)"
}
]
}
],
"sendResultOnPageNext": true,
"showProgressBar": "top",
"clearInvisibleValues": "none"
}

This is the Json.
And I have to get the Result 2 message in my json.
Please Refer the attached screenshot .

Answers approved by surveyjs Support

created 5 years ago

Hello,

You can use the expression question. Here is the survey JSON:

JSON
{ "completedHtml": "{resultExpression}", "pages": [ { "name": "page1", "elements": [ { "type": "panel", "name": "panel2", "elements": [ { "type": "radiogroup", "name": "question7", "title": "Do You have fever? ", "isRequired": true, "choices": [ { "value": "Yes", "text": "Yes" }, { "value": "No", "text": "No" } ], "colCount": 0 } ] }, { "type": "radiogroup", "name": "question1", "title": "Do You have Cough?", "isRequired": true, "choices": [ { "value": "Yes", "text": "Yes" }, { "value": "No", "text": "No" } ], "colCount": 0 }, { "type": "expression", "name": "question2", "visible": false, "commentText": "Other (describe)" } ] }, { "name": "page2", "elements": [ { "type": "comment", "name": "question10", "visible": false, "title": "If Yes", "defaultValue": "Risk 1", "rows": 5 }, { "type": "comment", "name": "question14", "visible": false, "title": "If No", "defaultValue": "Risk 2", "correctAnswer": "Risk 2" }, { "type": "expression", "name": "resultExpression", "expression": "iif({question7} = 'Yes', 'Result 1', 'Result 2')", "commentText": "Other (describe)" } ] } ], "sendResultOnPageNext": true, "showProgressBar": "top", "clearInvisibleValues": "none" }

Thanks, Serge
SurveyJS Team

    Show previous comments (2)
    DB DB
    Deepika Bansal 5 years ago

      Thank You

      DB DB
      Deepika Bansal 5 years ago

        Hi,
        Here the expression used is "expression": "iif({question7} = 'Yes', 'Result 1', 'Result 2')",
        But I also want to Get Result 3 , Result 4 . If there are more options in question7 -like Yes, No , Does'nt want to answer the question, None
        And I want Result 1 on Yes , Result 2 on No, Result 3 on Does'nt want to answer the question, Result 4 on None.
        {
        "completedHtml": "{resultExpression}",
        "pages": [
        {
        "name": "page1",
        "elements": [
        {
        "type": "panel",
        "name": "panel2",
        "elements": [
        {
        "type": "radiogroup",
        "name": "question7",
        "title": "Do You have fever? ",
        "isRequired": true,
        "choices": [
        {
        "value": "Yes",
        "text": "Yes"
        },
        {
        "value": "No",
        "text": "No"
        }
        ],
        "colCount": 0
        }
        ]
        },
        {
        "type": "radiogroup",
        "name": "question1",
        "title": "Do You have Cough?",
        "isRequired": true,
        "choices": [
        {
        "value": "Yes",
        "text": "Yes"
        },
        {
        "value": "No",
        "text": "No"
        }
        ],
        "colCount": 0
        },
        {
        "type": "expression",
        "name": "question2",
        "visible": false,
        "commentText": "Other (describe)"
        }
        ]
        },
        {
        "name": "page2",
        "elements": [
        {
        "type": "comment",
        "name": "question10",
        "visible": false,
        "title": "If Yes",
        "defaultValue": "Risk 1",
        "rows": 5
        },
        {
        "type": "comment",
        "name": "question14",
        "visible": false,
        "title": "If No",
        "defaultValue": "Risk 2",
        "correctAnswer": "Risk 2"
        },
        {
        "type": "expression",
        "name": "resultExpression",
        "expression": "iif({question7} = 'Yes', 'Result 1', 'Result 2')",
        "commentText": "Other (describe)"
        }
        ]
        }
        ],
        "sendResultOnPageNext": true,
        "showProgressBar": "top",
        "clearInvisibleValues": "none"
        }

          Hello,

          I've created a separate ticket on your behalf (T4477: How to build the expression?). It has been placed in our processing queue and will be answered shortly.

          Thanks, Serge
          SurveyJS Team