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
subaasubaa 

LoginHistory API query

Hi,

 

I need to access LoginHistory API from a trigger to check whether the current record is updated/created from 'Application or Partner Product (Data Loader) or Synch (Lotus Notes)' using Login Type field.

 

Hope you got my scenario! And here how can i access current login user's detail and that to be linked with respective login history details.

 

Regards,

SuBaa

Ankit AroraAnkit Arora

Am not sure if we can get loginhistory in trigger, but you want to know which user is presently logged in then you can use UserInfo.getUserId() . For more information on it please visit :

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

UVUV

I don't think would be possible to find out whether record is created/edited by external tool or through UI.However, you can get login user details from the Loginhistory Sobject by simple query like-

SELECT UserId, LoginTime from LoginHistory;.

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_loginhistory.htm

 

Anis_SFDCAnis_SFDC

As to access LoginHistory object, you can use Apex Scheduler and query the Object if that works for you?

 

It did work for me but then there is a limit of 10 Apex jobs max at any time. Hence I can not schedule the job every 5 mins (I'd need 12 jobs) that too, assuming that no one else needs a job.

 

Did you find if there is a way to write trigger on LoginHistory?