We are currently working on a project that utilizes SurveyJS, and we have encountered a particular use case that we're facing difficulties with.
Project Overview:
We collect survey data and then the data is saved to our database in a structured manner. To achieve this, we have set up a functional chain for data-saving requests, which are sent separately for each panel/dynamic panel within the survey. Each panel's data is saved in a separate table in our database, with fields corresponding to the survey questions. We bulkify requests, so we send all records that are part of dynamic panel.
Current Workflow:
- When a user clicks the 'Complete' button, we initiate the data-saving functional chain.
- We trigger this chain during the
onServerValidateQuestions
event to ensure data validity. - In case there are any errors in the submitted data, we aim to highlight the fields that are to blame. We do this by assigning the question errors to the
event.errors
array, respecting the SurveyJS question name.
Issue Description:
Our current approach works effectively for most survey questions, as long as they are not nested in a dynamic panel. When attempting to highlight errors for questions that are nested within a paneldynamic
element. Specifically, the following code does not work as expected for such questions:
event['<Question Name>'] = '<error message>';
We have also tried alternative methods to address this issue, such as directly accessing the question's model instance and setting the .errors
property. Unfortunately, any native approaches do not seem to work for questions nested within a paneldynamic
. The issue is specific to questions within paneldynamic
elements, as it works perfectly fine for other survey elements.
Support Request:
We need guidance on how to natively highlight errors on questions that are children of paneldynamic
elements (or even dynamic panels nested within other panels/dynamic panels), in cases where the validation is performed programmatically or via server validation.
Your expertise in addressing this matter would be greatly appreciated, as it will significantly enhance the functionality of our survey application.
Thank you for your prompt attention to this request. We look forward to your guidance and assistance in resolving this issue.
Hello Alexander,
Thank you for reaching out. Unfortunately, the current
survey.onServerValidateQuestions
API doesn't seem to allow specify errors for individual Dynamic Panel elements. I forwarded the corresponding issue to our developers for further consideration: Enhance the survey.onServerValidateQuestions API to a Panel Dynamic usage - Highlight errors on questions which appear within a Panel Dynamic.We'll update you as soon as we get any information.
Thanks
Hello Jane,
I appreciate your prompt response. It's good to know that you've forwarded our issue to the developers for further consideration regarding the enhancement of the
survey.onServerValidateQuestions
API.In the meantime, as we continue working on our project, we're keen to explore alternative approaches to achieve the desired functionality of highlighting errors accurately, when dealing with nested elements within dynamic panels, and when validation is performed programmatically.
Could you kindly offer any suggestions or workarounds that might help us address this challenge effectively?
Thank you for your ongoing support, and we look forward to any guidance you can provide.
Best Regards,
Alexander