Show/hide Incident Choices for different company users and a Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 05:33 AM
Hi,
I have a requirement to create new categories and subcategories on Incident Table. Now the ask is to show the categories and subcategories only to users who belongs to a different company (different email id) and ServiceDesk group.
Can we show/hide choices based on logged in user mail id? A solution would be helpful.
Thanks in Advance,
Shruthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:44 AM - edited 11-26-2024 10:53 AM
Hi @Shruthi8 ,
You can achieve this through a display business rule and an onLoad client script on incident table.
Step 1: Create a display BR on incident table
Step 2: Fill the Condition field as : gs.getUser().getEmail().indexOf('@company.com')!==-1
(here we are checking if the current logged in user email contains '@company.com'. You should be changing this condition acc to your requirement's unique identification email.)
Step 3: Enter Script as below:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.userEmail=true;
})(current, previous);
(here we are getting a boollean check through g_scratchpad variable which can be callable in client script. Passing true because the current logged in user email belongs to '@company.com')
Step 4: Create an onLoad Client script on incident table with the script below
function onLoad() {
if(g_scratchpad.userEmail){
g_form.removeOption('category','application'); //directly removing category as there are no dependent subcategories attached to this category
g_form.removeOption('subcategory','os'); //removing all dependent subcategory for 'Software' Category
g_form.removeOption('subcategory','email'); //removing all dependent subcategory for 'Software'Category
g_form.removeOption('category','software'); //removing the category
}}
(here if you want to hide a category then you have to hide both category and all its dependent category in one go or else it wont hide.)
This is the only working solution I could come up with as there is not much flexibility in achieving this solution. If there are any pls let us know in this string.
Hope this helps, if the solution worked for you plz Accept the Solution and Mark it as Helpful so it could benefit fellow devs. Thank you!
Regards,
Muhammad Arafath