Retain theme on esc portal after clone

CV1
Tera Contributor

Hello Everyone,

We have 3 instances 1 prod and 2 non-prod (dev &UAT). The 3 instances have different Themes. 

We have a clone profile where during clone, Preservers > Preserve  theme is turned on.

The instances retain the different themes after clone.

 

The requirement is we would like to have same scenario on our ESC portal.

ie 
<Prod Instance>.service-now.com/esc = color1

<Dev Instance>.service-now.com/esc = color2

<UAT Instance>.service-now.com/esc = color3

 

Please advise how this can be addressed.

 

TIA

 

 

 

 

 

2 REPLIES 2

tejas1111
Giga Contributor

hi

Create a system property that uniquely identifies each instance.

Example:

  • Name: esc.instance.identifier

  • Type: String

  • Values:

    • On Prod: prod

    • On Dev: dev

    • On UAT: uat

⚠️ This property must be marked as "Preserve" in the clone profile so that it is not overridden.


2. Update your ESC theme logic (CSS or Theme record) to read this property and apply different styles accordingly.

 

 

  • Go to the ESC theme record (SP Theme).

  • Customize the CSS or CSS URL field.

  • In the CSS, use a GlideAjax call or script include to retrieve the esc.instance.identifier and apply a corresponding class to the <body> tag.

Or use a UI Script to inject a class based on the instance:

 

 

var ga = new GlideAjax('GetInstanceIdentifier');
ga.addParam('sysparm_name', 'getIdentifier');
ga.getXMLAnswer(function(response){
  var identifier = response;
  document.body.classList.add('theme-' + identifier);
});

 

 

Then in your portal CSS, define:

 

body.theme-prod {
  --primary-color: #123456;
}

body.theme-dev {
  --primary-color: #789abc;
}

body.theme-uat {
  --primary-color: #ffcc00;
}

 

script include

 

var GetInstanceIdentifier = Class.create();
GetInstanceIdentifier.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getIdentifier: function() {
        return gs.getProperty('esc.instance.identifier') || 'prod';
    }
});

 

 

 

 

palanikumar
Mega Sage

Hi,

How are you configuring the theme?

If you are configure it using "Service Portal Configuration", then all changes are captured in Service Portal record, so you need to preserve sp_portal.

If you are directly updating Theme, Header or Footer record then you need to preserve them

Thank you,
Palani