Recent searches
No recent searches

Paul Hughes
Joined May 13, 2021
·
Last activity Jul 17, 2024
Following
0
Followers
0
Total activity
66
Votes
10
Subscriptions
10
ACTIVITY OVERVIEW
BADGES
ARTICLES
POSTS
COMMUNITY COMMENTS
ARTICLE COMMENTS
ACTIVITY OVERVIEW
Latest activity by Paul Hughes
Paul Hughes commented,
Hi Johnny J Johnny J Noelle Cheng
I posted about this solution in 2023 but here it is again, if you want to hide a specific value in a dropdown see below, im using a nesty panel.
Full solution here:
Finding the ID in your HTML (Step 1)
First find the name of the dropdown ID.
To find the IDs of the options, you'll need to enable "Emulate a focused page" in the console. Here's how:
- Open the console in Chrome.
- Click the three dots in the top right corner.
- Go to "More tools" > "Rendering."
- Click on "Emulate a focused page."
Once you activate "Emulate a focused page," you can open the dropdown, and it will remain open, allowing you to hover over the options and view their IDs.
My ID on the dropdown was called ‘new_application_form'
--------------------
Adding code to script.js file (Step 2)
Now paste this code below into the bottom of your script.js file, In my case I have my knowledgebase open to the public, so anonymous can view it, in this example I want to hide this dropdown option from all users in my organization, these are Anonymous, Staff, Students. You can check yours under the admin portal – people – configuration – tags.. I could also just restrict one or two groups if I wanted.
Note, all you need to do is Replace the line ‘new_application_form’
with your dropdown ID. Apart from that paste is as is below.
// For this funtion to work i needed to call it in my script.js file first.
$(document).ready(function() {
var hideoption = document.getElementById('new_application_form');
if (HelpCenter.user.role == "anonymous" || HelpCenter.user.organizations[0].name == "Staff" || HelpCenter.user.organizations[0].name == "Student") {
if (hideoption !== null) {
hideoption.style.display = 'none';
}
var optionsToRemove = ['new_application_form'];
hideDropdownOptions(optionsToRemove);
}
});
// This will hide the option with the id demo_field if the user is anonymous.
function hideDropdownOptions(tagsToRemove) {
if (tagsToRemove) {
Array.prototype.forEach.call(document.querySelectorAll(".nesty-panel"), function(tagsElement) {
if (tagsElement !== null) {
var fieldDisableTagsObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == 'childList') {
if (mutation.addedNodes.length >= 1) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
for (var j in tagsToRemove) {
var tagElementToRemove = document.querySelector("li#" + tagsToRemove[j]);
if (tagElementToRemove !== null) {
tagElementToRemove.remove();
}
}
}
}
}
});
});
fieldDisableTagsObserver.observe(tagsElement, {childList: true});
}
});
}
}
This function checks if the user is anonymous. If so, it iterates over all elements with the class nesty-panel and sets up a MutationObserver to watch for changes in the DOM within these elements. When nodes are added to the DOM, it checks if the option with the id standard_request exists and removes it if found.
Make sure that:
- The HelpCenter.user.role correctly reflects the user's role.
- The class nesty-panel accurately identifies the elements containing the dropdown.
- The ID
new_application_form
matches the ID of the option you want to hide.
If everything is set up correctly, this code should hide the new_application_form
option for anonymous users and all signed in org users.
View comment · Edited Apr 25, 2024 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
I appreciate the explanation and thanks for coming back to me. I have a specific query based on information provided by the support team: is the assignment of tags to tickets dependent on the tags being part of the top 100 popular tags list in the admin center?
If that's the case, my concern is that my top 100 tags list is heavily populated with field values, making it challenging to observe normal keyword trends on a daily basis. What I'm looking for is a straightforward solution that can analyze all tickets and extract the most frequently used words over a given period, say a week. Is there a method to export tickets along with their text data? I'm also open to exploring third-party apps that can perform such analyses and I think there might be if I can get that data exported.
View comment · Posted Nov 23, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Team,
I'm a bit confused about my tagging setup. During a recent conversation with support, they mentioned that even with auto-tagging enabled, the tags wouldn't be assigned to a ticket unless they were part of the top 100 tags list. This seems counterintuitive because how am I supposed to identify emerging tags if they aren't applied to tickets? Do I need to manually add these tags to a ticket for them to appear in the top 100?
I've also observed numerous tags being applied based on field values, such as "registration_department" or "programme_enquiries." These tags don't seem to be added through triggers, leading me to believe they are applied when a field option is chosen and its tag is applied to the ticket, in the ticket event it just says Tags: Name of Tags . However, I prefer not to have these tags assigned to tickets.
Is there a method to prevent field values from being automatically applied as tags? As per my understanding, I need to manually input tags into the system before they appear in the top 100 list. Ideally, I'd like the top 100 list to display only those tags extracted from ticket descriptions and not the field values?
View comment · Posted Nov 22, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
Just to let you know I figured it out and am now hiding on of the options.
I found a similar forum about this issue here and was able to use this to create my own working piece of code.
---------------------------
For anyone coming along now just to be clear here's what I done to get it working.
In the script.js file of my theme go to the bottom of the page and add.
// For this funtion to work i needed to call it in my script.js file first.
$(document).ready(function() {
hideDemoOptionForAnonymous();
});
// This will hide the option with the id demo_field if the user is anonymous.
function hideDemoOptionForAnonymous() {
if (HelpCenter.user.role === "anonymous") {
Array.prototype.forEach.call(document.querySelectorAll(".nesty-panel"), function(tagsElement) {
if (tagsElement !== null) {
var fieldDisableTagsObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == 'childList') {
if (mutation.addedNodes.length >= 1) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
var demoFieldToRemove = document.querySelector("li#standard_request");
if (demoFieldToRemove !== null) {
demoFieldToRemove.remove();
}
}
}
}
});
});
fieldDisableTagsObserver.observe(tagsElement, {childList: true});
}
});
}
}
Another thing to note:
In order to find the option id's you need to enable emulate a focused page in the console, you can google this or
open console in chrome
click the three dots top right
more tools - rendering
click on emulate a focused page
once you turn on emulate you can open the dropdown and it will stay open so you can hoover over the options and read the id.
View comment · Edited May 04, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Thanks for helping and providing the code.
I was wrecking my brain trying to get this to work before I stumbled onto your code.
For anyone coming along now just to be clear here's what I done to get it working.
In the script.js file of my theme go to the bottom of the page and add.
// For this funtion to work i needed to call it in my script.js file first.
$(document).ready(function() {
hideDemoOptionForAnonymous();
});
// This will hide the option with the id demo_field if the user is anonymous.
function hideDemoOptionForAnonymous() {
if (HelpCenter.user.role === "anonymous") {
Array.prototype.forEach.call(document.querySelectorAll(".nesty-panel"), function(tagsElement) {
if (tagsElement !== null) {
var fieldDisableTagsObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == 'childList') {
if (mutation.addedNodes.length >= 1) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
var demoFieldToRemove = document.querySelector("li#standard_request");
if (demoFieldToRemove !== null) {
demoFieldToRemove.remove();
}
}
}
}
});
});
fieldDisableTagsObserver.observe(tagsElement, {childList: true});
}
});
}
}
Another thing to note:
In order to find the option id's you need to enable emulate a focused page in the console, you can google this or
open console in chrome
click the three dots top right
more tools - rendering
click on emulate a focused page
once you turn on emulate you can open the dropdown and it will stay open so you can hoover over the options and read the id.
example: you can see the id for this option is standard_request.
View comment · Posted May 04, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
I still cant get it working, I went back to your original idea:
Can I ask, im adding this in the script, do i need to add in any code before the if query? Function or For?
if (HelpCenter.user.role=="anonymous"){
document.querySelector("#demo_field").style.display="none";
}
View comment · Edited May 03, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
Thanks for coming back so fast, I know what you are saying now thanks for clearing that up, I don't think this will work for me in that case as I don't have the same HTML code, it only shows me the field ID for the whole field and doesn't contain a separate ID for its values which is annoying. That's why I was using the tag originally. We don't have access in Zendesk to edit this HTML on specific fields as they are all created under the Zendesk admin portal.
|
|
View comment · Posted Apr 28, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
Im not trying to hide the field here, only one of the field values, in this case that value is demo and its tag is demo.
So when you say it should be field id: demo should the field ID be incorporated in this code somewhere, I have tried many alternatives to this code snippet but cant get it working.
View comment · Posted Apr 28, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
I tried that and it didn't work for me, I was just trying from anonymous user view and it wasn't hiding the field value in the dropdown.
In my field values I am trying to hide the Demo one,
if (HelpCenter.user.role=="anonymous"){
document.querySelector("#demo").style.display="none";
}
View comment · Posted Apr 27, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments
Paul Hughes commented,
Hi Ifra Saqlain
Would you know if this is possible, you were very knowledgeable about hiding forms in the past.
View comment · Posted Apr 25, 2023 · Paul Hughes
0
Followers
0
Votes
0
Comments