Survey is showing error - "You have already submitted the response", even when user has not filled the survey yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 03:40 AM
Hi Everyone,
We are trying to restrict users from retake survey using this business rule. But the business rule is not working as expected. Could anyone help me understand what might have caused the issue. The screenshot of the issue is attached.
FYI - We are using customized notification for sending out the surveys, which has survey link embedded in the notification content itself.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery('trigger_id',current.trigger_id);
gr.query();
while(gr.next())
if(gr.trigger_id == current.trigger_id){
{
current.setAbortAction(true);
gs.addErrorMessage("You have already submitted the response.");
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2022 09:53 PM
Hello Zia,
Could you please check with below script in your after update BR:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("asmt_assessment_instance");
gr.addEncodedQuery("trigger_id=" + current.getValue("trigger_id") + "^state=complete^assigned_to=" + current.assigned_to);
gr.query();
if(gr.next()) {
if(gr.trigger_id == current.trigger_id) {
current.setAbortAction(true);
gs.addErrorMessage("You have already submitted the response. Hence this survey response is not submitted");
}
}
})(current, previous);
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 11:39 PM
Hello Zia,
Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.
If you still need any further help or guidance on this then please update those on this question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 06:19 AM
Hi Mahendra,
Thanks for your response. But we have identified that the assessment instances which are getting generated when user clicks on the link provided in the notification email, have empty trigger_id. And as this business rule was around trigger ids, it is throwing unexpected errors.
But we had already addressed this issue with the help of sysparm parameters earlier. But I think something has gone wrong and the issue has appeared again. I am still trying to figure out what might have gone wrong.
Just for your reference, we have added below line in our notification's survey link after type_id.
sysparm_trigger_table=sn_customerservice_case&sysparm_trigger_id=${sys_id}
It was earlier filling the trigger ids, But now.... it stopped working magically. :'(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 10:55 PM
Hello Zia,
Then could you please let me know what is your use case because if you don't have the trigger id on your assessment instance record then how will you indentify if the user has already submitted the survey.
My assumption was that you are trying to restrict the users from taking again for same incident.
For example 2 survey were triggered for INC0034232 then if the user has taken 1 survey and he tries to submit the 2nd second for same INC0034232 then he should not be able to do.
Is your use case different?
Thanks