Recent searches


No recent searches

Zendesk redirects to "My activities" after submitting even when required fields are empty



Posted Apr 01, 2024

I'm currently experiencing the issue that Zendesk is redirected end users to the My Activities page even if the required fields are left blank.

I was checking the backend and could see that no tickets were created. But no error message appeared that required fields are empty and redirected users to the My Activities page.

 

Previously, I was trying to implement said code from article https://support.zendesk.com/hc/fr/community/posts/4409515169946-Requiring-a-ticket-attachment-if-a-particular-dropdown-option-is-selected

 

I suspected that this was the issue, so I've removed the code again. But I'm still getting the same issue. 

 

I am trying to force end users to provide attachments if they choose a specific value in a drop down field. 

 

 


0

2

2 comments

After testing, I found out that the issue was the mandatory checkbox. Removed said box and the errors show up again. 

I would still need to have attachments mandatory. 

 

I've modified the script in the post above and enabled the attachment field when the drop down option is selected. So that works. Even if an attachment is uploaded, it ticks the box. But if end users click on submit without filling in mandatory fields. No error shows up and they are getting redirected. Do mandatory checkboxes not work? 

 

  
// Can't submit damage ticket without attachment
var startObserveMutations = function(nodeSelector, options, callbackFunction) {
 var node = document.querySelector(nodeSelector);
 if (node) {
   var observer = new MutationObserver(callbackFunction);
   observer.observe(node, options);
   return observer;
 }
};
// Callback function to execute when mutations in form attachments are observed:
// clear or select Attachment checkbox according to attachments
var mutationObservedForm = function(mutationsList) {
 mutationsList.forEach(function(mutation) {
   if (mutation.type === 'childList') {
     setFormAttachmentCheckbox();
   }
 });
};
// Define some variables for requiring form attachments
var attachmentCheckboxField = 'request_custom_fields_30367309244953';
var attachmentCheckboxId = '#' + attachmentCheckboxField;
var attachmentErrorNotification = 'Attachments cannot be blank';
var formDropdownClass = '.request_custom_fields_19906073817113';
var formObserveMutationOptions = { childList: true, subtree: true };
// Clear or select checkbox according to attachments:
// Set Attachment checkbox if at least one attachment is uploaded, otherwise clear it
function setFormAttachmentCheckbox() {
 if ($('#request-attachments-pool .upload-item').length >= 1) {
   selectCheckbox(attachmentCheckboxId);
 } else {
   clearCheckbox(attachmentCheckboxId);
 }
}
// Select checkbox
function selectCheckbox(eltselector) {
 $(eltselector).prop('checked', true);
}
// Clear checkbox
function clearCheckbox(eltselector) {
 $(eltselector).prop('checked', false);
}
// If attachment checkbox field exists:
//   Watch for changes to attachments
if ($(attachmentCheckboxId).length) {
 startObserveMutations('#request-attachments-pool', formObserveMutationOptions, mutationObservedForm);
}
// Adjust attachment error notification
var attachmentErrorElt = $(attachmentCheckboxId + ' .notification-error');
if (attachmentErrorElt.length) {
 attachmentErrorElt.text(attachmentErrorNotification);
}
// Initial checkbox setting
setFormAttachmentCheckbox();

0


Update:

I got this code working for my instance (Copenhagen theme). Added to script.js.

You need to create a check box (call it whatever you want. I called mine Attachments) and make it mandatory to submit a ticket.

 

Add the Checkbox to the form you want to use at the very bottom. Copy the ID for both the drop down menu where you need attachments and check box and remove the X's with the corresponding IDs.

 // Can't submit damage ticket without attachment
var startObserveMutations = function(nodeSelector, options, callbackFunction) {
 var node = document.querySelector(nodeSelector);
 if (node) {
   var observer = new MutationObserver(callbackFunction);
   observer.observe(node, options);
   return observer;
 }
};
// Callback function to execute when mutations in form attachments are observed:
// clear or select Attachment checkbox according to attachments
var mutationObservedForm = function(mutationsList) {
 mutationsList.forEach(function(mutation) {
   if (mutation.type === 'childList') {
     setFormAttachmentCheckbox();
   }
 });
};
// Define some variables for requiring form attachments
var attachmentCheckboxField = 'request_custom_fields_XXXXXX';
var attachmentCheckboxId = '#' + attachmentCheckboxField;
var attachmentErrorNotification = 'Attachments cannot be blank';
var formDropdownClass = '.request_custom_fields_XXXXXX';
var formObserveMutationOptions = { childList: true, subtree: true };
// Clear or select checkbox according to attachments:
// Set Attachment checkbox if at least one attachment is uploaded, otherwise clear it
function setFormAttachmentCheckbox() {
 if ($('#request-attachments-pool .upload-item').length >= 1) {
   selectCheckbox(attachmentCheckboxId);
 } else {
   clearCheckbox(attachmentCheckboxId);
 }
}
// Select checkbox
function selectCheckbox(eltselector) {
 $(eltselector).prop('checked', true);
}
// Clear checkbox
function clearCheckbox(eltselector) {
 $(eltselector).prop('checked', false);
}
// If attachment checkbox field exists:
//   Watch for changes to attachments
if ($(attachmentCheckboxId).length) {
 startObserveMutations('#request-attachments-pool', formObserveMutationOptions, mutationObservedForm);
}
// Adjust attachment error notification
var attachmentErrorElt = $(attachmentCheckboxId + ' .notification-error');
if (attachmentErrorElt.length) {
 attachmentErrorElt.text(attachmentErrorNotification);
}
// Initial checkbox setting
setFormAttachmentCheckbox();    

Lastly, add this to style.css hide the check box field in the form. Replacing the X's with the checkbox ID

 

#request_custom_fields_XXXXXX_label,
#request_custom_fields_XXXXXX {
display: none;
}

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post