Ricerche recenti
Nessuna ricerca recente

C A
Data ingresso 14 mar 2024
·
Ultima attività 25 apr 2024
Seguiti
0
Follower
0
Attività totali
13
Voto
1
Abbonamenti
3
PANORAMICA ATTIVITÀ
BADGE
ARTICOLI
POST
COMMENTI NELLA COMMUNITY
COMMENTI AGLI ARTICOLI
PANORAMICA ATTIVITÀ
Ultima attività di C A
C A ha commentato,
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);
}
}
Visualizza commento · Data ultimo post: 25 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha commentato,
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
Visualizza commento · Data ultimo post: 24 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha commentato,
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 {
Visualizza commento · Data ultimo post: 23 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha commentato,
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;
}
Visualizza commento · Data ultimo post: 01 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha commentato,
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;
}
Visualizza commento · Data ultimo post: 01 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha commentato,
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();
Visualizza commento · Data ultimo post: 01 apr 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha creato un 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.
Data ultimo post: 01 apr 2024 · C A
0
Follower
1
Voto
2
Commenti
C A ha commentato,
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');
}
});
Visualizza commento · Data ultimo post: 15 mar 2024 · C A
0
Follower
0
Voti
0
Commenti
C A ha creato un 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");
Data ultimo post: 14 mar 2024 · C A
0
Follower
2
Voti
2
Commenti