LoginAsEvent
LoginAsEvent tracks when an admin logs in as another user in your
org. In Real-Time Event Monitoring, it captures events for org admins and Experience
Cloud sites only. LoginAsEvent is a big object that stores the event data of
LoginAsEventStream. This object is available in API version 46.0 and
later.
Supported Calls
describeSObjects(), query()
Special Access Rules
Accessing this object requires either the Salesforce Shield or Salesforce Event Monitoring add-on subscription and the View Real-Time Event Monitoring Data user permission.
Fields
Standard SOQL Usage
Currently, the only supported SOQL function on LoginAsEvent is WHERE, and you can only use comparison operators (=,
<, >, <=, and >=) on the final expression in a WHERE clause. The != operator isn’t supported.
LoginAsEvent allows filtering over two ordered
fields: EventDate and EventIdentifier.
There’s a catch here; your query doesn’t work unless you use the correct order and
combination of these fields. The following list provides some examples of valid and
invalid queries:
-
Unfiltered
-
Valid—Contains no WHERE clause, so no special rules
apply.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent
-
Valid—Contains no WHERE clause, so no special rules
apply.
-
Filtered on EventDate
-
Valid—You can filter solely on
EventDate, but single filters on other
fields fail. You can also use a comparison operator in this query
type.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent 3WHERE EventDate<=2014-11-27T14:54:16.000Z -
Valid—You can filter on EventDate
using date
literals.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent 3WHERE EventDate<=TODAY
-
Valid—You can filter solely on
EventDate, but single filters on other
fields fail. You can also use a comparison operator in this query
type.
-
Filtered on EventDate and
EventIdentifier
-
Valid—Successful queries on LoginAsEvent filter over both
fields.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and EventIdentifier='f0b28782-1ec2-424c-8d37-8f783e0a3754' -
Invalid—Queries on LoginAsEvent with
EventDate and standard date
literals.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent 3WHERE EventDate=TODAY and EventIdentifier='f0b28782-1ec2-424c-8d37-8f783e0a3754' -
Invalid—Filtering only on
EventDate with <= or >= operator and
EventIdentifier field isn’t
supported.
1SELECT Application, Browser, EventDate, EventIdentifier, LoginHistoryId, UserId 2FROM LoginAsEvent 3WHERE EventDate<=2014-11-27T14:54:16.000Z and EventIdentifier='f0b28782-1ec2-424c-8d37-8f783e0a3754'
-
Valid—Successful queries on LoginAsEvent filter over both
fields.