Inactive Users (User Query) Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2016 09:36 AM
Happy Weekend everyone.
So i'm having an issue with the 'user query' business rule. hear me out.....
I understand and know what it does. but i need to exclude 1 form from the global business rule.
So we DO NOT want to show deactivated user on all forms. However, we have a reactivation form.
But the reactivation form does no good because of this BR. This form should ONLY show deactivated users.
I need a way to get a form value on ess or in the service catalog, and to not run this business rule if the reactivation form is selected.
I cant find anything on the community or wiki on how to exclude 1 form.
So we want to keep this rule acive but add a condition on there that only excludes the reactivation form.
I have tried a script with no success.
getItem();
function getItem(){
var itemID = current.cat_item.sys_id;
gs.addInfoMessage("Testing Item: " + itemID);
//application Access
if(itemID == '4b241c322be99200fb4c779217da15a6'){
//gs.log("Application access Request" + itemID);
return;
}
else{
current.addActiveQuery();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2016 09:36 PM
Not sure I understand what you mean? The script above should only work for one specific variable. If that variable is being used across multiple items, it should work on each of those items. However, it must be the same shared variable (likely through a variable set). The sys ID in the line 1 of the script above specifies the variable you don't want the business rule running for. If you're not using the same exact variable in other catalog items, that script will not work as expected.
If you're trying to do it for different fields on different tables (Incident, Change, etc.), you will need to alter the script to account for the field on those tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 07:31 PM
Yes, i understand what you are saying.
but what i'm saying is that there are some fields that show inactive users and some that dont. this did not occur until i added that code to the BR.
Turning that code off, the fields all act normal and end users cannot see the inactive users again.
Turn the code back on, and random fields show inactive users, random ones dont.
I cant put my finger on it either.
NONE of the fields have the same sys_id, i have verified that and so has my coworker.
Plus i now have 1 more issue.
I can see the inactive user, with end users.
I can use a client script to pull the sys_id and pass it to a Script include.
however, the query in the Script Include does not work on the sys_id because the current (end user) does not have access to inactive records on the user table.
so i have a sys_id and that's it.
is there a way to run a script include as an admin user rather than the user who called it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:32 PM
Ah, I see what you mean now. For the first problem, could you insert a message to see what the script is passing to the checkVar variable?
var checkVar = gs.action.getGlideURI().toString().indexOf("53c60a5b4582b100752effb4ad8f6c66"); // Check if the URL contains your variable you want to show all users for
gs.addInfoMessage("checkVar = " + checkVar);
if(checkVar == -1){ // If the URL does NOT contain the variable, add the active query (-1 means no match to the variable sys ID above)
current.addActiveQuery();
}
For your second issue, I'm not aware of any way to run the script include as another account (e.g. admin). However, I'm not sure this is the problem if they are able to select the inactive user in the variable. I would think if they can read the name to select it in the variable, they should be able to read the record in a query as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 06:05 AM
i've already done a gs.addinfomessage to the loading of the form.
one thing i can tell is that it's pulling sys_id's but none of them match my current field that i'm excluding, and inactive users are still being shown. it's really weird.
after some quick testing i was able to edit your script and use the following, and this seems to work correctly from all my testing.
checkRequest();
function checkRequest(){
var access = gs.action.getGlideURI().toString().indexOf("573410722be99200fb4c779217da1590");
if (access > -1){
//gs.addInfoMessage("Variable Found");
return;
}
else{
current.addActiveQuery();
}
}
So thanks for that.
that still leaves me with 1 issue, which i have opened a HI ticket for.
that the script include still doesn't work (even though it's server side) it's being run by someone without access to the sys_user table's inactive accounts..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 04:14 AM
Hi Steven,
I had the same requirement and used your code in user query BR.
Thanks & Regards,
Bhoomika