How to redirect home page based on csm agents role sn_customerservice_agent

ashok17
Tera Contributor

Hello All,

 

How to achieve the below requirement in servicenow:

 

How to redirect csm workspace view home page based on csm agent - role sn_customerservice_agent

 

and we tried updated on below script on script include "SPEntryPage" but it's not works on impersonate to the user role of ' 'sn_customerservice_agent' redirect to csm workspace view. Please suggest on this:

 

 if (user.hasRole('sn_customerservice_agent') && !user.hasRole('admin') && !redirectURL && !isServicePortalURL)
return "now/cwf/agent/home";

7 REPLIES 7

@ashok17 

thanks for sharing the screenshots

the link I shared earlier will work for you

Homepage Redirect Rules in Next Experience

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Tanushree Maiti
Tera Patron

Hi   @ashok17 

 

Initially can you just add mentioned snippet and if it works then update your code.

 

  • Navigate to System Definition > Script Includes and search for SPEntryPage.
  • Locate the getFirstPageURL function.
  • Insert the following condition 

 

if (gs.hasRole('sn_customerservice_agent'))

 {

    return "/now/cwf/agent/home";

}

Refer: KB0746730 How to configure user redirects in Service Portal 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Hi @Tanushree Maiti ,

 

I have already updated script in the script include but not works , means when ever to impersonate login the below role it's not redirecting the csm workspace view

 

Referred to by property: glide.entry.first.page.script
*
**/
getFirstPageURL: function() {
var session = gs.getSession();
this.logProperties('before', session);

// has roles and is not a Service Portal page - go to UI16
var nt = session.getProperty("nav_to");
var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(nt);
var redirectURL = session.getProperty("login_redirect");

if (user.hasRole('itil') && !redirectURL && !isServicePortalURL)
return;

if ((user.hasRole('RI+') || user.hasRole('provider')) && !redirectURL && !isServicePortalURL)
return "/now/sow/list";

if (user.hasRole('sn_customerservice_agent') && !user.hasRole('admin') && !redirectURL && !isServicePortalURL)
return "now/cwf/agent/home";