UI Script is not working in Polaris?

Community Alums
Not applicable

Hi All,

I have created one UI Script to show the 'switch to portal' option below the user dropdown on the home page. It's working fine in UI16 but it's not working in Polaris UI. Below is my code.

(function(){
    addLoadEvent(function(){
        try{
            var addItem = (window.top.$j("#custom_menu_item_1").length == 0);
            if (g_user.hasRoles() && addItem) {
                var menuItem = "<li><a id='custom_menu_item_1' href='/sp' target='_blank'>" + getMessage("Switch to Portal") + "</a></li>";
                var menuList = window.top.$j("ul.dropdown-menu");
                if(menuList.length >= 0){
                   
                window.top.$j("ul.dropdown-menu li:eq(0)").after(menuItem);
					
                }

            }
        }catch(e){

        }
    });
})();

 

Please suggest me on this. Thank You!

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

HELLO @Ganesh Manasali yes this is expected as polaris is built using different language UI script will not add the menu item under the profile menu.

its only possible in UI 16 and as of now there is no work around that i can see

please mark my answer correct if it helps you

 

Muhammad Khan
Mega Sage
Mega Sage

Hi, 

This article will https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1116237 help you understand.

 

Hopefully, it will help you.

wow @Muhammad Khan this is helpful for me too as i was struggling to do this 

@Ganesh Manasali try following this article

Community Alums
Not applicable

@Mohammed Khan Actually I am pretty new to UI Script. I have gone through the suggested KB and not able to conclude, what exact modification I need to do. Could you please help me with this?

I am trying to add one option under the user profile but i am not sure, how I can use client script to call the UI Script which i have createdd.

Thanks in advance.

Regards,

Ganesh