You need to sign in to do that
Don't have an account?

how to capture last login date time using batch apex
Hi,
How to captute user last login date in custom object .
You need to sign in to do that
Don't have an account?
Hi,
How to captute user last login date in custom object .
In batch apex you can write easy query - SELECT LastLoginDate FROM User
Basically I have capture the last login date time history of user in my custom object hed__Application__c.
Here is my code.. as I am getting error too.FATAL_ERROR System.QueryException: unexpected token: '('
global class LastLoginDateTime implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
system.debug('query' + query);
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<hed__Application__c> scope){
Schema.User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
system.debug('user>>>' +u);
list<hed__Application__c> hedApp=[select id,Login_History__c from hed__Application__c];
// Iterate through the whole query
for(hed__Application__c a : scope) {
a.Login_History__c = u.LastLoginDate;
}
update hedApp;
}
global void finish(Database.BatchableContext BC){
}
}