Capture User Login Data in custom table

Sonu Parab
Mega Sage
Mega Sage

Hello All,

 

We have one requirement such that,

1. A schedule job that runs daily at 1 am to capture user login events from previous day.

2. Schedule job identify login event from the previous day and extract relevant information, including user record, created date and instance.

3. For each login event, a new record should be created in the custom table "User Login Details"(we have created this custom table) with following details.

 

1. User: The user record associate with the login event.

2. Date: The created date from the login event.

3. Session ID: The Instance captured from the the event.

 

The User, Date, Session ID are the fields we have created on the custom table "User Login Details".

 

Could anyone please assist to achieve above requirement.

Thank you.

3 REPLIES 3

OlaN
Giga Sage
Giga Sage

Hi,

What is the purpose of this requirement?

You already have most of the data stored in the system, there is an event in the event registry that logs all user logins, and sets some data on the user record.

If looking at the user table, you can filter on all records that have "Last login" on Today

VaranAwesomenow
Mega Sage

If I understand correctly, your usecase is to track user login and logout activity to map it against subscription management ?
If yes, you can create a custom table and either use v_user_session or https://<instanceName>.service-now.com/sysevent_list.do?sysparm_query=sys_created_onONToday%40javasc...

as source of data

then write a scheduled job tat runs daily and stores data from one of the above sources to your custom table.

Hope tat helps.

let me know how it goes.

ersureshbe
Giga Sage
Giga Sage

Hi, Yes - Last login ID, last login date time fields play the main role in getting the value. If you want to push the value from the user table, you should write the scheduled job and schedule it based on your expectations. So custom table gets the data from the User table with the help of a Scheduled Job.

Regards,
Suresh.