function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sochy_EisenbergSochy_Eisenberg 

LoginHistory: Workaround for Filtering Query on Application Field

Hi guys,

I'm trying to filter a SOQL query on the LoginHistory object using the Application field. Apprrently, this is not possible since 'Application' is not filterable (curious as to why that is.) I'm wondering if there is any workaround to this limitation, assuming I need to filter the information in Application to achieve my goal.

Thanks!
Best Answer chosen by Sochy_Eisenberg
Alain CabonAlain Cabon
@Yissochor Eisenberg

There are three other objects: LoginEvent, LoginGeo and LoginIp.

But the field Application is never filterable par SOQL.

So the only trivial workarounds are the export of the login history (csv+java./python) ( Setup > Login History ) or to use a filter on another field like the logintime.
select id, userid, logintime, application from loginhistory where logintime = THIS_MONTH

A batch can also read the LoginHistory object regularly and load a new custom object where the new field Application__c is now filterable (or by using dataloader reloading the exported csv file).
 

All Answers

Alain CabonAlain Cabon
@Yissochor Eisenberg

There are three other objects: LoginEvent, LoginGeo and LoginIp.

But the field Application is never filterable par SOQL.

So the only trivial workarounds are the export of the login history (csv+java./python) ( Setup > Login History ) or to use a filter on another field like the logintime.
select id, userid, logintime, application from loginhistory where logintime = THIS_MONTH

A batch can also read the LoginHistory object regularly and load a new custom object where the new field Application__c is now filterable (or by using dataloader reloading the exported csv file).
 
This was selected as the best answer
Sochy_EisenbergSochy_Eisenberg
Thank you, Alain!