- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 11:44 AM
All,
I created a display business rule to capture the logged in users role and hide Manager form section tab. Then created an onLoad Client Script to trigger the g_scratchpad variable and if true display the form section tabs else hide. This is all being done on the task table so that it can be used on Incident, Problem, Change. It all seems to work, but i guess not if the tabs don't display when testing with Service Manager role
Display BR
g_scratchpad.user = gs.getUser().hasRole('cde965c0dba96b00145b3a8c7c96199d'); //sys_id of the Role and I have tried it with g_scratchpad.user = gs.getUser().hasRole('Service Manager');
onLoad Client script:
if(g_form.getTableName() == 'incident' || g_form.getTableName() == 'change_request' || g_form.getTableName() == 'problem') {
if (g_scratchpad.user == 'true'){
//execute code
//var sections = g_form.getSectionNames();
g_form.setSectionDisplay('problem_manager',true);
g_form.setSectionDisplay('incident_manager',true);
g_form.setSectionDisplay('change_manager',true);
}
else{
g_form.setSectionDisplay('problem_manager',false);
g_form.setSectionDisplay('incident_manager',false);
g_form.setSectionDisplay('change_manager',false);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 12:56 PM
Actually, you should be able to use:
if (g_user.hasRole('Service_Manager')) {
//your code here
}
...directly in your Client Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 12:09 PM
Here it is:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:47 AM
Just seeing if anyone else has any suggestions. I looked at other posts and this is he way they are creating the logic. I guess i need to disable the display BR and put it directly in the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:55 AM
Did you try an alert on what the value of g_scracthpad.user is?
One last guess is that it is actually a boolean, and thus != 'true'
You can prove this out with the below background script
if (true == 'true') {
gs.print('True!');
} else {
gs.print('False!');
}
And one suggestion. If you stick with this route, rename the scratchpad variable you are using to make it more descriptive/less likely for someone else to step on it later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:53 AM
This test came back with False!
Thank you for the tip. I did change the scratchpad variable to be more descriptive and also updated the client script with the new variable name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:05 AM
Display Business rule:
if (gs.getUser().getRoles().indexOf('your role name') >= 0)
{
g_scratchpad.user='true';
}
else
{
g_scratchpad.user='false';
}
rest you client script will work.