Recent searches


No recent searches

Hide a module if a user is not of a specific organization



Posted Sep 02, 2024

Good evening,

 

i tried to follow the steps described in this article:

 

https://support.zendesk.com/hc/it/articles/4408886229146-Come-posso-nascondere-i-moduli-ticket-in-base-all-organizzazione-di-un-utente?page=1#comment_7939267795610

 

In particular i did that:

 

  1. i created a new module
  2. i created a new organization
  3. i copied this scritp in the bottom part of script.js file of the customer care portal
    
    $(document).ready(function() {
      var formID = 6502769669773; // Change this to the form ID you wish to remove
        var userOrgs = window.HelpCenter.user.organizations;
        var userOrgNames = userOrgs.map(org => org.name);
    
    if (!(userOrgNames.includes("ZENDESK"))) { // Specify the organization name here
    
          // If the user does not belong to the organization specified, remove the form option from the dropdown
          $('#request_issue_type_select option[value="' + formID + '"]').remove();
          $('.nesty-panel').on('DOMNodeInserted', function(e) {
            $(this).children('ul').children().remove('#' + formID);
          });
        }
      });
  4. I changed the formID with the module ID i just created
  5. I changed the userOrgNames with the name of the organization i just created
  6. I published the changed
  7. I tried to login with a final user that is not part of the new organization (but i had the same result with a user that is part of the new organization)
  8. I still see in the combo box list my new module name

There is someone that implemented the same changes with success that can give me some hint?

 

Alessandro Caldani


0

2

2 comments

Hi Alessandro Caldani,

I know it's been some time since you posted this question here, just curious if you were able to get this working?  If not, perhaps I could help you troubleshoot.

0


image avatar

Elaine

Zendesk Customer Care

Hi Alessandro,
 
It looks like you've put in a lot of effort to implement the changes outlined in the article. Here are a few suggestions that might help you troubleshoot the issue:
 
  1. Double-Check Form ID and Module ID: Ensure that the form ID and module ID you copied are correct and associated with the right organization.
     
  2. Inspect the Script for Errors: Look for any JavaScript errors in the console that may indicate why the dropdown isn't updating.
     
  3. Verify Organization Name: Make sure that the organization name you specified in the script matches exactly what’s in the system (case-sensitive).
     
  4. Review CSS Selectors: Confirm that the jQuery selectors ($('#request_issue_type_select option[value="' + formID + '"]')) are targeting the right elements on the page.
     
  5. Clear Cache: Sometimes changes might not appear due to caching. Clearing your browser cache or checking in an incognito window could help.
     
  6. Testing Alternative Users: If possible, test with different user accounts that belong to the new organization to see if the behavior varies.
     
If someone else has implemented similar changes successfully, it would be great for them to share their experience.
 
Let us know how it goes!
 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post