Inactive Users (User Query) Business Rule

Steven Young
Tera Guru

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

  }

}

13 REPLIES 13

top_tanti
Tera Expert

I was able to do this by referencing the sys_id of the variable. The caveat is that this variable cannot be used on other items (unless you want it to show inactive users as well).



For example, the sys ID of my variable is 53c60a5b4582b100752effb4ad8f6c66. See the example below for how I modified the business rule:



var checkVar = gs.action.getGlideURI().toString().indexOf("53c60a5b4582b100752effb4ad8f6c66"); // Check if the URL contains your variable you want to show all users for


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


}




Edit: Just noticed you want to show only inactive users for this particular form. If that's the case, you could modify the script a bit.


if(checkVar == -1) {


        current.addActiveQuery();


} else {


      current.addQuery("active",false);


}


not a problem.   i can use the reference qualifier to not show the active users.



I'll give it a try and let you know.



Thanks.


That will work too (and better solution).


this seems to work intermittently.   i dont understand it.


it's like it works on some of the requests, but not others.


this one field is ONLY on this 1 form and it works.


but like on an Incident or Change it doesn't work.