Question T11708
Visible to All Users

hasComment property not working properly in a custom question

created 2 years ago

Hi Team,

I have created a custom question called photo and i have added hasComment as a property of boolean type in general section. Its default value is false. When i select this value in UI and if i check in json editor, the value for hasComment is not getting updated to the json. I am currently using surveyjs version 1.9.66. Please find the below sandbox link to check the scenario.

https://codesandbox.io/s/nostalgic-ioana-w8pk5s?file=/src/SurveyCreatorComponent.jsx

Thanks,
Nisvin Shaffee

Comments (1)

    Hello Nisvin,
    We'll research this issue and get back to you shortly.

    Answers approved by surveyjs Support

    created 2 years ago

    Hello Nisvin,
    Thank you for your patience. A custom hasComment property doesn't appear in JSON editor because it conflicts with the hasComment property which is already declared for a survey Question class. To resolve the conflict, please specify another name for your custom property. If you wish to use the Has Comment display name, define the displayName property.

    JavaScript
    Serializer.addClass( "photo", [ { name: "hasCommentCustom:boolean", displayName: "Has Comment", default: false, category: "general", visible: true } ], null, "empty" );

    The updated example is available at https://codesandbox.io/s/sleepy-perlman-wqrwqs?file=/src/PhotoQuestion.js.

    Please let us know if you have any questions or require further assistance.

      Show previous comments (9)

        Hello Nisvin,

        When you say hasComment property will be always replaced with showCommentArea property, does that mean if I am loading a form which was created using an older surveyjs version, where its json key is hasComment and now when I open this form again using latest version, that hasComment key will get automatically replaced with showCommentArea?

        Yes. If your survey uses a legacy hasComment option, this option will be replaced with a new showCommentArea option if you open this survey in Survey Creator of the latest version.
        For example:

        Code
        {      "type""ranking",      "name""smartphone-features",      "title""Please rank the following smartphone features in order of importance:",      "isRequired"true,      "hasComment"true,      "choices": [       "Battery life",       "Screen size",       "Storage space",       "Camera quality",       "Durability",       "Processor power",       "Price"      ] }

          Hi Jane,

          Thanks for your feedback and support on this ticket. However, we see that compatibility aspect for forms designed using previous versions has been compromised in version 66 and some guidance on recommended migration path would really help. So, can you please confirm what will happen to forms created with hasComment when these forms are opened in runtime?

          Regards,
          Priyank

            Hello Priyank,
            You can patch your JSON from SurveyJS Creator before saving it into database.
            Here is the example.

            Thank you,
            Andrew
            SurveyJS Team