Survey-library: Manual trigger complete

Created on 17 Oct 2019  路  9Comments  路  Source: surveyjs/survey-library

I do validation on back-end and then get the object which contains the name of the incorrect field and message to it. When I speak about a name, it is the same as I get from SurveyModel.data.
I need to set up an error in my survey model. I found only that I can do it with "surveyValidateQuestion" function. But for this, I have to trigger this function from my own function where I get a response from back-end. I know, that this event is triggered with a complete button.
So my question is, how can I manually trigger a complete survey event.
I have read a lot about triggers in JSON with certain questions, but it is not my case. And doCopmlete() does not work because it skips"onServerValidateQuestions" event

question

Most helpful comment

@Vladqqqqoo It does. Here is the example.

Thank you,
Andrew

All 9 comments

@Vladqqqqoo You may have "run expression" trigger. You may add a custom function. The custom function may access the current survey as: this.survey and may call this.survey.doCompete(); to complete the survey when you need to.

Thank you,
Andrew

@andrewtelnov
I'm sorry, but perhaps you didn't understand me correctly.I will try to explain with more details. The main idea of my project it is not to depend from front-end part. That is why I don't want to write certain name of function in my json model. I want clear json schema without any dependencies in it.
What I have right now:
Firs of all, I get ready json schema from back-end and then set up it in survey model on front-end application. On each change in any field I get data with "syrveyModel.data" and send it to back end. My server validates it and sends me incorrect name of field(s) and error message(s) to it. I get this response in my function where I have sent request.
What I expect:
I want to set up this error and its message in my syrveyModel to certain field(s).

@Vladqqqqoo Do you need to validate all fields at ones?
You may review some our examples with server validation with different approaches. You may use any of them. Here is the link.

Thank you,
Andrew

@andrewtelnov I validate all fields at ones on each model onChange event. I have learned all yours ways to validate data. And they are not for my situation, because they validate only when I press "complete button". Please, read attentive my previous comment. The best way for me from your topics it is server validation, but it works only when I press "complete button", how can I avoid this and trigger it manually in order to trigger .onServerValidateQuestions event and then call onServerValidateQuestions callback

@andrewtelnov I try to figure out what happens when I click complete button. Because when I click this button - event "onServerValidateQuestions" works, if I call doComplete() function, it doesn't work. Could you help me, please.

@Vladqqqqoo Please call survey.completeLastPage();

Thank you,
Andrew

@andrewtelnov thank you! But it still doesn't trigger onServerValidateQuestions event... (

@Vladqqqqoo It does. Here is the example.

Thank you,
Andrew

@andrewtelnov Thank you a lot! I fixed my problem.

Was this page helpful?
0 / 5 - 0 ratings