Recent searches
No recent searches

C A
Joined Mar 14, 2024
·
Last activity Apr 25, 2024
Following
0
Followers
0
Total activity
13
Vote
1
Subscriptions
3
ACTIVITY OVERVIEW
BADGES
ARTICLES
POSTS
COMMUNITY COMMENTS
ARTICLE COMMENTS
ACTIVITY OVERVIEW
Latest activity by C A
C A commented,
Noelle Cheng You can always use a second script to change the wording and remove it from the main script
// Function to replace text
function replaceText(element, oldText, newText) {
if (element.innerText) {
element.innerText = element.innerText.replace(oldText, newText);
} else if (element.textContent) {
element.textContent = element.textContent.replace(oldText, newText);
}
}
View comment · Posted Apr 25, 2024 · C A
0
Followers
0
Votes
0
Comments
C A commented,
Noelle Cheng, I copy pasted the code from my instance. You would just need to make sure that you swap out the IDs.
In the bit where you check for a certain drop down value var formDropdownClass =
I have multiple drop down options added, as I needed to have attachments mandatory for multiple forms.
// Can't submit supply variance or 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_19908729240857, .request_custom_fields_30367309244953';
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();
That's how it looks like if no attachment is added
View comment · Posted Apr 24, 2024 · C A
0
Followers
0
Votes
0
Comments
C A commented,
Noelle Cheng Did you swap out the XXXXX for your field ID?
e.g.:
var attachmentCheckboxField = 'request_custom_fields_XXXXXX';
var attachmentCheckboxId = '#' + attachmentCheckboxField;
var attachmentErrorNotification = 'User request template must be attached';
var formDropdownClass = '.request_custom_fields_XXXXXX';
#request_custom_fields_XXXXXX_label,
#request_custom_fields_XXXXXX {
View comment · Posted Apr 23, 2024 · C A
0
Followers
0
Votes
0
Comments
C A commented,
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;
}
View comment · Posted Apr 01, 2024 · C A
0
Followers
0
Votes
0
Comments
C A commented,
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;
}
View comment · Posted Apr 01, 2024 · C A
0
Followers
0
Votes
0
Comments
C A commented,
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();
View comment · Posted Apr 01, 2024 · C A
0
Followers
0
Votes
0
Comments
C A created a post,
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.
Posted Apr 01, 2024 · C A
0
Followers
1
Vote
2
Comments
C A commented,
Hi Jakub
I've managed to by adding this at the end of the script.js
document.addEventListener('DOMContentLoaded', function() {
// Function to replace text
function replaceText(element, oldText, newText) {
if (element.innerText) {
element.innerText = element.innerText.replace(oldText, newText);
} else if (element.textContent) {
element.textContent = element.textContent.replace(oldText, newText);
}
}// Replace text for the specific anchor with href="/hc/en-nz/requests"
var linkElement = document.querySelector('a[href="/hc/en-nz/requests"]');
if (linkElement) {
replaceText(linkElement, 'My activities', 'My requests');
}
});
View comment · Posted Mar 15, 2024 · C A
0
Followers
0
Votes
0
Comments
C A created a post,
Is it still possible to adjust the text that is on the drop down menu and change the text from My Activities to My Requests
Tried both and added them to script.js but no luck so far
//Change string for My Activities
$('.user-nav .my-activities').html(' See my requests');
$('.sub-nav').find('li').filter(":last");
and
//Change string for My Activities
$('.nav-wrapper .dropdown-menu .my-activities').html('My Requests');
$('.sub-nav').find('li').filter(":last");
Posted Mar 14, 2024 · C A
0
Followers
2
Votes
2
Comments