The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Hide costum tabs on ui builder - workspace

Alessia Russo
Tera Expert

Hi, 

I'm tring to hide 3 tabs that I've created on workspace (SIR module) and I can't do it even with a client script on the ui builder. This is my code:

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
* @Param {any} params.imports
* @Param {ApiHelpers} params.helpers
*/
function handler({ api, event, helpers, imports }) {
    const c = api;
    if (!c.data) return;

    function setTabVisibility(tabLabel, visible) {
        let attempts = 0;
        const maxAttempts = 20; // circa 4 secondi
        const interval = 200;   // ogni 200ms

        const timer = setInterval(() => {
            attempts++;

            // Cerca il pane "left"
            const leftPane = document.querySelector('.left-pane');
            if (!leftPane) return; // se non esiste ancora, riprova al prossimo intervallo

            // Cerca i tab all'interno del left-pane
            const tabs = Array.from(leftPane.querySelectorAll('[role="tab"]')).filter(tab => {
                return tab.innerText.toLowerCase().includes(tabLabel.toLowerCase());
            });

            // Se trovi i tab o hai superato i tentativi massimi
            if (tabs.length > 0 || attempts >= maxAttempts) {
                tabs.forEach(tab => {
                    tab.style.display = visible ? 'block' : 'none';
                    tab.setAttribute('aria-hidden', visible ? 'false' : 'true');
                });
                clearInterval(timer);
            }
        }, interval);
    }

    // Controlla i dati
    const showInDora = c.data.u_in_dora === true || c.data.u_in_dora === 'true';
    const showInPsnc = c.data.u_in_psnc === true || c.data.u_in_psnc === 'true';

    // Applica visibilità ai tab
    setTabVisibility('InDora', showInDora);
    setTabVisibility('InDora285', showInDora);
    setTabVisibility('InPsnc', showInPsnc);
}
 
Could you help me? There's some fix to do to my script or another way?
Thank you
 
#workspace #uibuilder
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Alessia Russo 

see this link where I was able to hide Overview tab for Problem record in SOW

follow similar steps for your workspace, there is another approach as well mentioned there

How do I delete the overview tab 

below response from above link

AnkurBawiskar_0-1757070459096.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Alessia Russo 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader