• sindhu123
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi all,

I'm trying to create a batch apex to capture system generated lastlogindate on to custom field.But this is firing an error.

Here is the code

global class CaptureLastLoginDate implements Database.Batchable<sObject>{
 
    //This is the query that is passed to the execute method.  .
    
    String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
 
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
 
    }
    //close start method
 global void  Execute(Database.BatchableContext BC, List<User> scope) {
 User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
 
      
       // Iterate through the whole query
        for(User a : scope) {
            
                a.LastLoginDate__c = u.LastLoginDate;
            } //close if statement
         update LastLoginDate__c;
         }
        
        //close for-loop
      
     //close execute method
 
    global void finish(Database.BatchableContext BC) {
 
        
    } //close finish method

 

Could anyone help me.Thank you in advance

error:

Error: Compile Error: Argument type of global method must also be global: LIST<User> at line 12 column 15