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

Hi Steven,



Sorry to bring such an old post back from the grave, but did you receive a solution from HI regarding your Script Include?



Regards,



Robin


Mike W_
Tera Contributor

Hi All,

First off, thanks Top for the solution, I just used it!  Also, for anyone who wants this to work on the Service Portal too, you'll need to add a second URL check.  The asynchronous SP grabs don't include the sysID of the variable/catalog item in them, but they do include them in the referer field.  Here's the script I used:

 

checkRequest();

function checkRequest(){

var checkUrlVar = gs.action.getGlideURI().toString().indexOf("[sysID]");
var checkRefererVar = GlideTransaction.get().getRequest().getHeader("referer").toString().indexOf("[sysID]");

if ((checkUrlVar != -1 || checkRefererVar != -1)){
// gs.addInfoMessage("Variable Found");
return;
}
else {
current.addActiveQuery();
return;
}
}

Thanx for sharing this. I ended up using the variable sysID for the catalog check, and the catalog item sysID for the Service Portal check.

-Stephen

Reyes
ServiceNow Employee
ServiceNow Employee

so essentially

//this check is for platform, which works for checking if variable is used
var checkUrlVar = gs.action.getGlideURI().toString().indexOf("[sysID_of_variable]");

//this check is for service portal, this works for checking if the catalog item is used.
var checkRefererVar = GlideTransaction.get().getRequest().getHeader("referer").toString().indexOf("[sysID_of_cat_item]");

Addtionally a reference qualifier can be added on the ref variable on sys_user table where active=false, in conjuntion with the modified user query business rule.