Issue: The 'None' selection is propagated to each checkbox question with the same 'valueName'.
My need:
I need to group all selected choices from multiple checkbox questions within one property. It seems that 'valueName' property is the right way to do it (https://surveyjs.io/form-library/documentation/design-survey/merge-question-values)). I also need to have a 'None' option.
But when a 'None' choice is selected, all checkbox questions with the same 'value Name' reflect that change automatically selecting the same choice.
In the example above, I have provided a unique choice name per question to avoid such value propagation for ordinal choice. That works fine. But not for the 'None' choice, I did not find a way to set a specific name for 'None' choice.
Please advice how I can make that work, Thank you.
Example to reproduce:
JSON{
"title": "Incorrect behavior None option with valueName",
"pages": [
{
"name": "page1",
"elements": [
{
"type": "checkbox",
"name": "question1",
"valueName": "mergedValue",
"choices": [
{
"value": "question1.item1",
"text": "Item1"
}
],
"showNoneItem": true
},
{
"type": "checkbox",
"name": "question2",
"valueName": "mergedValue",
"choices": [
{
"value": "question2.item1",
"text": "Item1"
}
],
"showNoneItem": true
}
]
}
],
"showQuestionNumbers": "off"
}
Hello,
The
valueName
is a correct way to share the same value for survey elements. The None item is a part of a question value, therefore, it's value is also shared. If you wish to specify a different value for checkbox items and None items, why you use thevalueName
then? Would you please elaborate on your overall usage scenario?To simplify the automatic data processing of submissions, I need to have some values grouped at one 'parent' property. (''mergedValue' in my example). Therefore, in my case, it is more about grouping than merging. That is why to prevent actual value merging I'm using unique selection names. Basically, desired submission as I'd like to have:
{ "question1": "value", "question2": "value", // more data "dataForAutomaticProcessing":[ "qustion29.selectionItem12": "value", "qustion30.None": "true", "qustion31.None": "true", "qustion32.selectionItem10": "value", "qustion32.selectionItem12": "value", ] }
Hello,
I have just checked the behavior and it works correctly. If it would work differently then we would consider it as a bug and I believe many our customers would complain about it. In your particular scenario, you will have to write a code to achieve the required behavior. You can merge the data of your two checkbox questions on complete as you need.
Thank you,
Andrew
SurveyJS Team
Andrew, I understood, thank you for the clarification.
What I'm thinking about: the ability to set desired names to built-in choices, preserving default behavior if no value set, would allow to fulfill both cases and assumable will not lead to any complains.
In regard to writing manual code, it was attempted, but original None behavior resets values, and I can't figure out how that can be done in pure JSON schema (I'd like to avoid any component creation or modification of the default Survey behavior such as event processing specific for that case).
Is it possible to achieve like a default 'None' deselect all all other options in 'Creator' w/o any specific code written?
Thank you.
PS If that matters, I'm asking that question on behalf of the team that has Basic licenses.
Hello,
I would add a custom property "mergeOnComplete" and don't use "valueName" at all.
You can set this custom property to the needed value for your questions and then "onComplete" event merge values of questions with the same non-empty "mergeOnComplete" properties as you need.
It would extend our library with the functionality you need and make your code generic, so you can re-use it for many questions and surveys.
This is the correct way to go.
Thank you,
Andrew
SurveyJS Team
Thank you for answering. custom property still require to write the code. So that will not be as generic as I want it to be. As soon as there are no other options to achieve desired level of generality, I definitely use onComplete handler with manual transformations.
I am sorry, but I would not agree with you on this. You can make your code generic and re-use it in different projects.
It doesn't matter where the code is located in surveyjs packages or in your own JavaScript files. At the end it does what needs to be done.
If we include all possible functionality in our libraries, we will make it harder for developers to use our libraries and it will be harder for us to implement new functionality or make a refactoring. Tons of API that used by couple developers (every single functionality is used by 1-3 developers and unused by tens of thousands) will not help to support the product and move it forward.
I mean some functionality is better to have out of the box, some functionality is better to have outside the project.
PS: I was in the business of writing libraries, mostly commercial libraries, since 1997 and I made many mistakes and learned some things :-).
Thank you,
Andrew
SurveyJS Team
At least it is a matter of effort and the side that puts in this effort. :)
Then, you probably agree that from the functional completence for 'one item,' (https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#noneItem)), it is logical to have not only 'value' and 'text' but 'name' as well. And that does not cause any impact on any existing usage scenario.
Anyway, thank you for the answers.
You are very welcome!
Andrew
SurveyJS Team