Can we apply a custom theme to specific group members?

SaadK
Tera Expert

I have created a custom theme using the theme builder. I need to apply this theme to only one group, the 'TEST Group'. How can we achieve this?

4 REPLIES 4

pratikjagtap
Giga Guru

Hi @SaadK ,

 

Try below steps:

 

  • Create a Custom Theme:

    • You mentioned this is already done using the Theme Builder.

  • Find the Theme Sys ID:

    • Navigate to System UI > Themes, and copy the sys_id of your custom theme.

  • Create a Script to Apply Theme for TEST Group Users: You’ll need to use a Business Rule or a scheduled script to assign a UI Preference to all users in the "TEST Group".

Example Script to Assign Theme:

 

var group = new GlideRecord('sys_user_group');
group.addQuery('name', 'TEST Group');
group.query();
if (group.next()) {
var groupId = group.sys_id.toString();

var userGroup = new GlideRecord('sys_user_grmember');
userGroup.addQuery('group', groupId);
userGroup.query();

while (userGroup.next()) {
var userId = userGroup.user.toString();

// Check if preference already exists
var pref = new GlideRecord('sys_ui_pref');
pref.addQuery('user', userId);
pref.addQuery('name', 'glide.ui.theme');
pref.query();
if (!pref.next()) {
var newPref = new GlideRecord('sys_ui_pref');
newPref.initialize();
newPref.user = userId;
newPref.name = 'glide.ui.theme';
newPref.value = '<YOUR_THEME_SYS_ID>'; // Replace with your theme's sys_id
newPref.insert();
}
}
}

 

Test the Users in the TEST Group:

  • Ask a user from the TEST Group to log in.

  • The custom theme should be applied for them.

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik

 

What should be condiion, table & trigger for Business Rule & for a scheduled script what should be trigger.

Hi @SaadK ,

 

Create a Business Rule on the sys_user_grmember table (when a user is added to TEST Group):

When: Insert

Condition: group.name == "TEST Group" 

 

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik

what should be table, trigger condition for Business Rule or for a scheduled script what should be trigger