You need to sign in to do that
Don't have an account?
Nidhi Tandel
This is my code and in which I am having error is "Illegal assignment from List<LoginHistory> to List<LoginHistory>".
global class LoginHistory implements Schedulable
{
global void execute(SchedulableContext ctx) {
List<LoginHistory> loginHistories = [SELECT ApiType,
ApiVersion,
Application,
Browser,
ClientVersion,
Id,
LoginTime,
LoginType,
LoginUrl,
Platform,
SourceIp,
Status,
UserId
FROM LoginHistory
WHERE LoginTime <: System.now()
AND LoginTime >: System.now().addMinutes(-1)];
if ( !loginHistories.isEmpty()) {
List<Cg_LoginHistory__c> lhc = new List<Cg_LoginHistory__c>();
for (LoginHistory lh: loginHistories) {
lhc.add(new Cg_LoginHistory__c( ApiType__c = lh.ApiType ,
ApiVersion__c = lh.ApiVersion ,
Application__c = lh.Application ,
Browser__c = lh.Browser ,
ClientVersion__c = lh.ClientVersion ,
Id__c = lh.Id ,
LoginTime1__c = lh.LoginTime1 ,
LoginType__c = lh.LoginType ,
LoginUrl__c = lh.LoginUrl ,
Platform__c = lh.Platform ,
SourceIp__c = lh.SourceIp ,
Status__c = lh.Status ,
UserId__c = lh.UserId
));
}
insert lhc;
}
}
}
{
global void execute(SchedulableContext ctx) {
List<LoginHistory> loginHistories = [SELECT ApiType,
ApiVersion,
Application,
Browser,
ClientVersion,
Id,
LoginTime,
LoginType,
LoginUrl,
Platform,
SourceIp,
Status,
UserId
FROM LoginHistory
WHERE LoginTime <: System.now()
AND LoginTime >: System.now().addMinutes(-1)];
if ( !loginHistories.isEmpty()) {
List<Cg_LoginHistory__c> lhc = new List<Cg_LoginHistory__c>();
for (LoginHistory lh: loginHistories) {
lhc.add(new Cg_LoginHistory__c( ApiType__c = lh.ApiType ,
ApiVersion__c = lh.ApiVersion ,
Application__c = lh.Application ,
Browser__c = lh.Browser ,
ClientVersion__c = lh.ClientVersion ,
Id__c = lh.Id ,
LoginTime1__c = lh.LoginTime1 ,
LoginType__c = lh.LoginType ,
LoginUrl__c = lh.LoginUrl ,
Platform__c = lh.Platform ,
SourceIp__c = lh.SourceIp ,
Status__c = lh.Status ,
UserId__c = lh.UserId
));
}
insert lhc;
}
}
}
Let me know in which line you are getting this error. I tried your Login History Query in developer console and was working fine.
Are you getting this error when saving the class or when executing the class.
Thanks
Manoj S