how Redirect Home Page to Vendor Workspace

armanoj
Mega Sage

Hi Team,

How to redirect user home landing page to Vendor Workspace for the users with vendor accessor role . 

4 REPLIES 4

Tanushree Maiti
Tera Patron

Hi @armanoj 

 

1) If you want  globally effective override on login that applies regardless of the UI, you can modify your base system entry script

Refer: Role based redirection with SPEntryPage

 

2) you can utilize either the Next Experience Homepage Redirect Rules

Homepage Redirect Rules in Next Experience

 

 

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

Venky Kshatriy2
Mega Sage

Hi @armanoj 

Role-based login redirect using SPEntryPage (best for your requirement)

Steps to configure
1) Find the Vendor Workspace URL
Open Vendor Workspace and copy the relative path from the browser URL.
Example format could be something like:
Plain Text/now/vendorworkspace/homeShow more lines

2) Create a new Script Include by extending SPEntryPage
Create a new Script Include, for example: VendorEntryPage.

Use this sample:

var VendorEntryPage = Class.create();
VendorEntryPage.prototype = Object.extendsObject(SPEntryPage, {

 

    initialize: function() {
        this.VENDOR_WORKSPACE = "/now/vendorworkspace/home"; // replace with your real Vendor Workspace URL
        this.CLASSIC_HOME = "/now/nav/ui/home";
    },

 

    getFirstPageURL: function() {
        var session = gs.getSession();
        var nt = session.getProperty("nav_to");
        var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(nt);
        var redirectURL = session.getProperty("login_redirect");

 

        // Always keep admin check first
        if (user.hasRole('admin')) {
            return this.CLASSIC_HOME;
        }

 

        // Redirect vendor users to Vendor Workspace
        if (user.hasRole('vendor_accessor') && !redirectURL && !isServicePortalURL) {
            return this.VENDOR_WORKSPACE;
        }

 

        // fallback to default OOB behavior
        if (!redirectURL) {
            var sPage = session.getProperty("starting_page");
            if (sPage && nt == "welcome.do")
                nt = sPage;

 

            var ep = gs.getProperty("glide.login.home");
            if (nt) {
                if (ep == nt)
                    nt = null;
            }

 

            if (nt == "welcome.do") {
                session.putProperty("nav_to", ep);
                return;
            }

 

            session.putProperty("login_redirect", nt || "true");
            return "/login_redirect.do?sysparm_stack=no";
        }

 

        session.clearProperty("login_redirect");
        session.clearProperty("nav_to");

 

        if (redirectURL && redirectURL.indexOf("sys_attachment.do") > -1)
            return redirectURL;

 

        var returnUrl = this.portal;
        if (redirectURL && redirectURL != "true") {
            var spUrl = new GlideSPScriptable().mapUrlToSPUrl(redirectURL);
            returnUrl = spUrl ? this.portal + "?" + spUrl : redirectURL;
            if (!user.hasRoles() && !spUrl && redirectURL.indexOf("home_splash.do") > -1)
                returnUrl = this.portal;
        }

 

        return returnUrl;
    },

 

    type: 'VendorEntryPage'
});



Create these properties if they do not already exist:
glide.entry.first.page.script = new VendorEntryPage().getFirstPageURL();
glide.entry.page.script       = new VendorEntryPage().getLoginURL();

After saving:

Ankur Bawiskar
Tera Patron

@armanoj 

you can handle this using Homepage Destination Rule

Homepage Redirect Rules in Next Experience 

High level steps

  1. Create a New User Criteria for users with the Vendor Accessor role but excluding the sn_sow.sow_home roles, or based on specific conditions that match your user subset.
    • gs.hasRole('vendor_accessort') && !gs.hasRole('sn_sow.sow_home') && !gs.hasRole('sn_sow.sow_list')
  2. Add a New Homepage Destination Rule with higher priority (order field lower than the existing SOW rule) that points to your custom UI Builder page, assigned to the new User Criteria.
  3. Deactivate or lower precedence of the existing SOW homepage destination rule if possible, or rely on your new rule taking priority.

💡 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