logo

NJP

How to get inactive user records in catalog item look up field?

Import · Nov 10, 2020 · article

The motivation to write this article comes from this post. https://community.servicenow.com/community?id=community_question&sys_id=336b4737db45d850190dfb243996...

There was a requirement to build a catalog form for rehiring candidates . So we had to create a lookup field on catalog which should show inactive user records.

So by default there is a business rule called "User Query" which is a before query business rule which restricts and shows only active records in both portal and classic view. So we had to do a workaround to make things work.

Thanks to community as always.

Long story cut short .. So here's the code.

  • Edit the business before query business rule and make these changes.
  • We don't need to change business rule condition
var checkVar = gs.action.getGlideURI().toString().indexOf("5e769c02db3998106a8d92b8f49619ec"); //sys_id of the reference field on the catalog form

var checkRefererVar = GlideTransaction.get().getRequest().getHeader("referer").toString().indexOf("c3d19c4adbf598106a8d92b8f49619d9"); //sys_id of the catalog item

if(checkVar != -1 || checkRefererVar != -1){

}

else {

current.addActiveQuery();

}

This code will work like charm and it will show you inactive records on portal. Best part is we can also do the same for a variable set and re use the variable set.

Kindly mark this article as helpful if this solves your requirement. Let me know if you have any queries.

Thank you!.

View original source

https://www.servicenow.com/community/itsm-articles/how-to-get-inactive-user-records-in-catalog-item-look-up-field/ta-p/2315426