itil user whom can not belong to specific group members are also redirect to the SOW page

sandeep sahu
Tera Contributor

Hello Experts,
I wanted to redirect the selected user.Criteria groups with itil role members to redirect to SOW landing page, But the user whom can not belongs to the group but has itil role has also redirect to SOW page. how can I restrict if the user with itil role but can not belong to the group is redirect to the native page.

 

Thank You 

1 REPLY 1

Deepak Shaerma
Kilo Sage

Hi @sandeep sahu 
ensure the user criteria groups you referenced are well-defined and include all and only those members you wish to redirect to the SOW page. This grouping mechanism will be key to distinguishing between users.

#A UI Script or a Global UI Action can be used to run JavaScript on the client side. This script will check the conditions (i.e., the user’s group membership and their roles).

##Script Include or Business Rule. This is for conceptual demonstration purposes and would need adjustments to fit your exact requirements:


(function() {
var user = gs.getUser(); // Get current user object
var userId = user.getID(); // Get user sys_id
var redirectToSOW = false; // Flag to determine redirect action

if (user.hasRole(‘itil’)) { // Check if user has ‘itil’ role
// Check if the user belongs to any user criteria group specific for SOW redirection
var grpMemberGR = new GlideRecord(‘sys_user_grmember’);
grpMemberGR.addQuery(‘user’, userId);
grpMemberGR.query();
while (grpMemberGR.next()) {
var group = grpMemberGR.getValue(‘group’);
// Here you would check if the group matches your criteria
// Example: if(group == ‘your_specific_group_sys_id’)
// Assuming ‘isSOWRedirectGroup’ is a function you’d implement to check if the group
// is one of those designated for SOW redirection based on sys_id or another identifier
if (isSOWRedirectGroup(group)) {
redirectToSOW = true;
break; // User meets criteria, break out of loop
}
}
}

if (redirectToSOW) {
// Logic to perform the redirection to the SOW landing page
// This could involve setting a URL parameter or using some other mechanism
gs.addInfoMessage(“Redirecting to SOW Page…”); // Example feedback
// Actual redirection could depend on where this check is implemented (e.g., in a UI Page script)
} else {
// Logic for redirecting to the native page or doing nothing
// Example: gs.addInfoMessage(“Accessing standard page…”);
}
})(); 

 Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma