Is it possible to control the display of the portal's logo/title according to the user's role?

Minamizono
Tera Contributor

We would like to change the visibility of the CSM Portal depending on the user. However, we want the URL to be the same for all users.
Is it possible to control the display of the CSM Portal logo/title according to the role of the user?


logo・・・ServiceNow
title・・・カスタマーサポート

Minamizono_0-1753837956698.png

 

1 REPLY 1

Shruti
Mega Sage
Mega Sage

Hi,

 

It is possible to show different logo and title without creating multiple portals 

1. Navigate to System UI -> Images

Upload logo for each role

2. Create a new system property to map logo  and title for each role

Name - portal.logo.title.mapping

Description - JSON Key - logo, title
                         JSON Value - image name uploaded in step 1 and title 

Value - 

{
"admin" : {
"logo":"logo1.svg",
"title":"Admin CSM"
},
"itil":{
"logo":"logo2.png",
"title":"ITIL CSM"
}
}

 

3. Navigate to Service Portal -> Portals and Open CSM portal Theme

Clone the out of the box header widget and update it to the theme

4. Open the cloned header widget

HTML - update the highlighted lines

Shruti_2-1753851352883.png

 

5. Add below lines to the server script

   
 var user_role='';
    if (gs.hasRole('admin')) {
        user_role = 'admin';
    } else if (gs.hasRole) {
        user_role = 'itil';
    }
   
    var val = JSON.parse(gs.getProperty('portal.logo.title.mapping'));
   
    if (val.hasOwnProperty(user_role)) {
        data.logo = val[user_role].logo;
        data.title = val[user_role].title;
    }

 

 

Also refer - https://www.servicenow.com/community/csm-forum/how-to-control-the-display-of-the-portal-header-logo-...