Using g_scratchpad in display Business Rule

Brett14
Giga Expert

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);
}
}

1 ACCEPTED SOLUTION

Actually, you should be able to use:

if (g_user.hasRole('Service_Manager')) {
  //your code here
}

...directly in your Client Script.

View solution in original post

18 REPLIES 18

rahulpandey
Kilo Sage
Hi Could you try putting alert in client script to check what is the value your getting from business rule. This is just make sure if busines rule is has issues. Also, just to check if logged user is not an admin, else you will not get expected results

Jim Coyne
Kilo Patron

This tool may help you out - "Show Contents of g_scratchpad" Tool.

Change your BR to:

g_scratchpad.user = gs.hasRole("whatever_role_name");

Hi Jim,

that didn't work.  Thank you for the utility.  I would need to see if i am able to place that in the environment.  So, till then I am at square 1.

Can you paste a screenshot of the Business Rule so we can see?