How to get a report of the users with the accesses they requested in Servicenow

nayanmule
Tera Expert

Hi All,

I have a query regarding the report. I want to get the report of the users who have been offboarded from the company.

I need the report to contain all the access requested by them, granted by them through various requests.

 

Access requests may be like SAP, Office licenses, JDE ..etc. requested through various request items.

 

Any help will be appreciated.

 

Thanks in Advance,

Nayan Mule

 

4 REPLIES 4

GlideFather
Tera Patron

Hi,
do you want to have just a report with the list of the users and their licenses or you also want to have a mechanism how to remove the licenses?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Just a report is enough

Do you have any pattern how to distinguish off boarded employees? 
- in my script I used condition: inactive users updated in last 7 days

And then you will need to find a pattern of the access request (either a category, one or more sys ids, ... depends on your company's data).


Then you can try to play with this background script:

//Query to the inactive users and updated in last 7 days - update up to your needs

var userGR = new GlideRecord('sys_user');
userGR.addEncodedQuery('active=false^sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
userGR.query();

while (userGR.next()) {
 
//users as seen above are checked for their requests
var catItemGR = new GlideRecord('sc_req_item');
catItemGR.addEncodedQuery('add_your_query'); //here you will have to specify what is the access request
catItemGR.query();

while (catItemGR) {
gs.print(userGR.name + ' - ' + catItemGR.name);
}
}

This is just a Friday afternoon's draft so take it with some reserve please 😄
———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Rick62
Tera Expert

@nayanmule,

How are the users related to the requests?  Are they the requested for?  Are they in a variable?  Are they referenced by sys_id?  Is it just a string with name or email address? 

The report logic is fairly simple.  Filter the access requests to your list and filter the users to your list of separated users.  If you used requested for then filtering for the users is easy....there's even a related list you can add to user records to see all their requests right there.....if the users are in variables and / or string fields....good luck