---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# PolarisUI - Scoped

# PolarisUI - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

The PolarisUI API provides methods for enabling Next Experience on direct UI pages.

A UI page \[sys_ui_page\] is direct if the Direct field is
Selected. A direct UI page doesn't include the common HTML page
template and must include all CSS and JavaScript that you want to use in the page.

All non-direct UI pages use Next Experience by default.

For more information about Next Experience, see [the Next Experience UI](https://www.servicenow.com/docs/access?context=next-experience-landing-page&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).

The PolarisUI API is provided within the `sn_ui`
namespace.

## PolarisUI - canUsePolarisCSS() {#ariaid-title2}

Checks if the current page can use the Next Experience UI.
This method returns `true` if all of the following conditions are met.

* sn_ui.PolarisUI.isEnabled() is `true`.
* The request URL parameter sysparm_use_polaris is not set to `false`.
* The referrer HTTP request header does not contain `sysparm_use_polaris=false`.
* The page or its parent plugin are not denied use of Next Experience by a record in the Page Theme Support \[sys_page_theme\] table.
{#PolarisUI-canUsePolarisCSS__ul_acr_xnb_vrb}

Use this method to conditionally change behavior or [jelly](https://www.servicenow.com/docs/access?context=r_JellyTags&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) output if Next Experience is enabled.
{#PolarisUI-canUsePolarisCSS__table_vzz_nkq_prb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#PolarisUI-canUsePolarisCSS__table_vzz_nkq_prb} {#PolarisUI-canUsePolarisCSS__table_wzz_nkq_prb__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current page can use the Next Experience UI. Valid values: * true: The current page can use the Next Experience UI. * false: The current page can't use the Next Experience UI. {#PolarisUI-canUsePolarisCSS__ul_pgy_hv2_5rb} |
[Table 2. Returns]

{#PolarisUI-canUsePolarisCSS__table_wzz_nkq_prb}  
This UI Action redirects to a different page if Next Experience is running on the
current form.

    var id = current.getUniqueValue();
    if (sn_ui.PolarisUI.canUsePolarisCSS())
    	action.setRedirectUrl("/now/custom/application/record/" + id);
    return "/record.do?sys_id=" + id;

This jelly script sets a different style sheet for pages using Next Experience.

    <g:evaluate var="jvar_css_path">
    	// Core UI content css record
    	var id = "5e8fde63d713310074304187ed61030d";

    	if (sn_ui.PolarisUI.canUsePolarisCSS())
    		id = "84f03cc87120a00cfab6dd207cb0b72";
    	
    	"/" + id + ".cssdbx";
    </g:evaluate>
    <link href="${jvar_css_path}" rel="stylesheet" type="text/css" />

## PolarisUI - getBodyClassNames() {#ariaid-title3}

Returns a list of CSS class names used by the Next Experience UI.
Use this method in the HTML `<body>` tag of a UI page to set the CSS classes required for Next Experience to render correctly.

    <body class="$[sn_ui.PolarisUI.getBodyClassNames()]">

The returned class names change depending on system properties and if session debug output
exists.
{#PolarisUI-getBodyClassNames__table_hkn_1lq_prb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#PolarisUI-getBodyClassNames__table_hkn_1lq_prb} {#PolarisUI-getBodyClassNames__table_ikn_1lq_prb__entry__2}

| Type | Description |
|-|-|
| String | List of CSS class names used by the Next Experience UI. |
[Table 4. Returns]

{#PolarisUI-getBodyClassNames__table_ikn_1lq_prb}  
This jelly script adds Next Experience to a custom UI page.

    <?xml version="1.0" encoding="utf-8" ?>
    <j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:g2="null">
        <g2:doctype name="html" />
        <g:inline template="dir_checker.xml"/>
        <html class="${jvar_text_direction}" lang="$[gs.getSession().getLanguage()]">
            <head>
                <g:inline template="set_theme_vars.xml" /> <!-- sets jvar_theme and jvar_css_cache_key -->
                <g:requires name="styles/css_includes_my_app.css" includes="true" params="$[jvar_css_cache_key]" /> 
                <g:if_polaris>
    	<g:then><g:inline template="polarisberg_output.xml"/></g:when>
    	<g:else><g:inline template="heisenberg_output.xml" type="css"/></g:else>
                 </g:if_polaris>
            </head>
            <body class="$[sn_ui.PolarisUI.getBodyClassNames()]">
                Your UI page content here
            </body>
        </html>
    </j:jelly>

## PolarisUI - isEnabled() {#ariaid-title4}

Checks if the Next Experience UI is enabled for the current user.
This method checks if the glide.ui.polaris.experience system property and glide.ui.polaris.use user preference are both set to true.

* glide.ui.polaris.experience enables Next Experience on the instance.
* glide.ui.polaris.use disables Next Experience for specified users when set to false.

{#PolarisUI-isEnabled__ul_hrj_nq2_5rb}For more information about Next Experience system properties and user preferences, see [Next Experience system
properties](https://www.servicenow.com/docs/access?context=pol-sys-properties&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).  
Note:  
This method returns true even if Next Experience is disabled for the current page. This method is useful for conditionally enabling entire experiences or redirecting to different pages when Next Experience is enabled globally.
{#PolarisUI-isEnabled__table_ljc_djq_prb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#PolarisUI-isEnabled__table_ljc_djq_prb} {#PolarisUI-isEnabled__table_mjc_djq_prb__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the Next Experience UI is enabled for the current user. Valid values: * true: The Next Experience UI is enabled for the current user. * false: The Next Experience UI isn't enabled for the current user. {#PolarisUI-isEnabled__ul_pgy_hv2_5rb} |
[Table 6. Returns]

{#PolarisUI-isEnabled__table_mjc_djq_prb}  
This UI page displays a conditional message to the user if Next Experience is
enabled for the current user.

    <j:if test="${sn_ui.PolarisUI.isEnabled()}">
    	<a href="...">Click here to learn more about the new UI changes</a>
    </j:if>

This business rule shows an info message on record display that a user can click to view
the record in Core UI instead of Next Experience. The business rule
Condition field is set to `!current.isNewRecord() &&
sn_ui.PolarisUI.isEnabled() && sn_ui.PolarisUI.canUsePolarisCSS()`.

    // business rule script field

    (function executeRule(current, previous /*null when async*/) {

    	var sysId = current.getUniqueValue();
    	gs.addInfoMessage("<a href='/incident.do?sys_id="+ sysId +"&sysparm_use_polaris=false'>Click here to load this page in Core UI</a>");

    })(current, previous);


