- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 06:41 AM
I am very new to SN and JS. I am trying to understand how to add multiple groups to the client and server scripts below. The script is used to limit who can open a priority 1 incident.
What is the syntax or proper method to add a second (or third group) group using this method (e.g. add a "mytestgroup2" group)? The easiest method I can think is to add a second business rule, but I am sure it is easier than that.
Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
//g_form.addInfoMessage('Scratchpad : ' + g_scratchpad.isMember);
//Called the g_scratchpad.isMember funtion within the Display Business Rule
if (g_scratchpad.isMember == true)
{
g_form.removeOption('impact', '1');
g_form.removeOption('urgency', '1');
}
}
Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.isMember = gs.getUser().isMemberOf('mytestgroup1');
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 07:09 AM
You can just add or condition in the BR
if(gs.getUser().isMemberOf('mytestgroup1') || gs.getUser().isMemberOf('mytestgroup2') || gs.getUser().isMemberOf('mytestgroup3')){
g_scratchpad.isMember=true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 07:28 AM
Zeller,
I advice you to do it in only one place, eitheir within a business rule (solution provided by Abhinay) or in a client script (Solution I provided above).
There is no much need to make a display business rule with scratchpad if the only one request is to hide one value depending on the user logged in.
That is my advice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2016 06:22 AM
Thank you everyone for your valuable input and taking time to respond. I am marking Abhinay's answer as correct because it was the quick fix I was looking for. However, I am still unsure why the consultant used this method--it seems like it will lead to issues later. I will continue to research and use everything you have provided. Thanks again to everyone!