Hiding a ticket form on the 'submit a request' page | Community
Skip to main content

Hiding a ticket form on the 'submit a request' page

  • August 12, 2021
  • 102 replies
  • 0 views

Show first post

102 replies

Ivan41
  • May 29, 2025

Hi all,

So I did upgrade my Jquery in the document head 
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>

and copy pasted this script under my script.js, but somehow it still shows the form.

var tagsToRemove = ['47456423349785'];
 

function removeTagsWeDontWant() {
   const removeNodes = (node) => {
       for (let i = 0; i < node.childNodes.length; i++) {
           const wasRemoved = removeNodes(node.childNodes[i]);
           if (wasRemoved) {
               i--;
           }
       }

       if (node.nodeType === 1 && tagsToRemove.includes(node.getAttribute("id"))) {
           node.parentNode.removeChild(node);
           return true;
       }
       return false;
   };

   const observer = new MutationObserver(mutationList =>
       mutationList.filter(m => m.type === 'childList').forEach(m => {
           m.addedNodes.forEach(removeNodes);
       }));
   document.querySelectorAll('.nesty-panel').forEach(panel => observer.observe(panel, {
       childList: true,
       subtree: true
   }));
}

 

removeTagsWeDontWant();


  • July 14, 2025

@ivan41  Not sure if this helps, but here is the script that I use based on user organization name and having it hide multiple internal forms if the user is not associated with the specific organization:

// Hide internal ticket form from users not associated with the organization (JD 20250709)
$(document).ready(function () {
  // Retrieve user organizations
  const userOrgs = window.HelpCenter.user ? window.HelpCenter.user.organizations : [];
  const userOrgNames = userOrgs.map(org => org.name);

  // Replace "ORGANIZATION NAME" with your target organization name
  if (!userOrgNames.includes("ORGANIZATION NAME")) {
    // Array of form names to hide
    const formsToHide = ["Test Form #1", "Test Form #2", "Test Form #3"]; // Add all INTERNAL FORM NAMES here

    // Function to hide the undesired options
    const hideFormOptions = () => {
      const comboboxOptions = document.querySelectorAll('[data-garden-id="dropdowns.combobox.option"]');
      comboboxOptions.forEach(option => {
        const optionName = option.textContent.trim();
        if (formsToHide.includes(optionName)) {
          option.style.display = "none";
          option.setAttribute("aria-hidden", "true");
          console.log(`Re-hidden form: ${optionName}`);
        }
      });
    };

    // MutationObserver to monitor changes to the dropdown
    const observer = new MutationObserver(() => {
      hideFormOptions();
    });

    // Initialize the observer for dropdown container
    const comboboxContainer = document.querySelector('[data-garden-id="dropdowns.combobox"]');
    if (comboboxContainer) {
      observer.observe(comboboxContainer, { childList: true, subtree: true });
    } else {
      console.warn("Combobox container not found, retrying...");
      setTimeout(() => {
        const retryContainer = document.querySelector('[data-garden-id="dropdowns.combobox"]');
        if (retryContainer) {
          observer.observe(retryContainer, { childList: true, subtree: true });
          hideFormOptions();
        }
      }, 500);
    }

    // Initial call to hide the form options
    hideFormOptions();
  }

  // Debugger in console. Replace "ORGANIZATION NAME" with your target organization name
  console.log("User Organizations:", userOrgNames);
  console.log("Forms hidden for user? ", !userOrgNames.includes("ORGANIZATION NAME"));
});