Employee Center Portal customization based on user roles

SNDP
Tera Contributor

Is it possible to customize the employee center homepage based on the roles they have, like, if user has no role it should redirect to different homepage and for approver roles should have different widgets on homepage

4 REPLIES 4

Pankaj kr
Kilo Sage

Yes, You can make widgets role based visible.

PritamG
Mega Guru

Yes, in ServiceNow, you can customize the Employee Center homepage based on user roles by using User Criteria to control widget visibility and sp_redirect or script includes for role-based redirection. Use g_user.hasRole('role_name') for conditional logic and assign specific portals or homepages for different roles in Portal Configuration.

yuvarajkate
Giga Guru

Yes, you can customize the Employee Center homepage based on user roles in ServiceNow. Use role-based redirection and widget visibility configurations to achieve this. For users without roles, create a rule to redirect them to a specific homepage. For users with roles like "approver," configure widget visibility or set up role-based homepages using Experience Builder.
Here is an example of how you can implement it in script:

Server Script to Check Role:

var RoleBasedRedirect = Class.create();
RoleBasedRedirect.prototype = {
    initialize: function() {},
    hasNoRoles: function() {
        return !gs.hasRoles();
    },
    type: 'RoleBasedRedirect'
};

Client Script to Redirect:

    api.controller = function ($scope, $window, spUtil) {
        $scope.handleUserRoles = function () {
            if (!g_user.hasRoles()) {
                $window.location.href = "/no-role-homepage";
            } else if (g_user.hasRole('xyz')) {
                spUtil.addInfoMessage('Welcome!');
            }
        };
        $scope.handleUserRoles();
    };

Rohit99
Mega Sage

Hi @SNDP,

Please have a look on this KB article - How to setup portal redirection based on different roles 

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi