• Raghu Cheruvu 1
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hi,

I am exporting data using apex data loader CLI. However, the columns in the exported file are all in upper case, even through in the mapping.sdl they are in lower case. 

COLUMN HEADERS Below:-

VEEVA_ID CONTACT_TITLE  CONTACT_FIRST_NAME   CONTACT_LAST_NAME 

below is the sdl which is used:-

Name=veeva_id
contact_title__c=contact_title
Account_vod__r.FirstName=contact_first_name
Account_vod__r.LastName=contact_last_name

i want the column headers of the extracted file to be in lower case, let me know if the column headers can be lower case.
Hi, 

i am getting OwnerId cannot be blank while populating OwnerId in a trigger, the trigger is working when i load the data using a batch size of 1, but when i use the batch size of 200, i am getting the error owner id cannot be blank ( i have highlighted the line at which error is occuring in bold)

trigger Account_Trigger on Account (after insert, after update) {

Map<String,User> UserDetailsMap=new Map<String,User>();
 Map<String,String> UserIdMap=new Map<String,String>();
 Map<String,String> UserMap=new Map<String,String>();
 Map<String,String> ZipTerrMap=new Map<String,String>();
List<Account> newAccountList=new List<Account>();
Map<String,String> Zip_TerrMap=new Map<String,String>();
Set<String> AccountZipSet=new Set<String>();
 Set<String> newAccountZipSet=new Set<String>();
Map<String,String> UserTerrMap=new Map<String,String>();
List<Zip_to_Terr_vod__c> ZipTerrList=new List<Zip_To_Terr_vod__c>();
 List<Account> UpdateAccountList=new List<Account>();
  List<Alert_vod__c> AlertList=new List<Alert_vod__c>();List<Alert_vod__c> ExistingAlertList=new List<Alert_vod__c>();
  Map<Id,Alert_vod__c> AlertMap=new Map<Id,Alert_vod__c>();Set<Id> AlertSet=new Set<Id>();
   List<Alert_vod__c> InsertAlertList=new List<Alert_vod__c>();
   Map<Id,Account> AccountMap=new Map<Id,Account>();
   Set<Id> AlertAccountIds=new Set<Id>();
   
 List<Account> newAccList=new List<Account>([Select Id,Primary_Zip__c,Assigned_Rep__c,Rep_Territory__c,MSL_Territory__c,
New_RX_Alert_Expiration_Date__c,New_RX_Date__c,Rep_Email__c ,New_Prescriber__c,New_Precription__c,Specialty_1_vod__c
 from Account where Id IN:Trigger.newMap.keySet()
 ]);
 
 Profile_Custom_Settings__c p= Profile_Custom_Settings__c.getValues('SampleInstance');
 
string profileid=p.ProfileId__c;

if(UserInfo.getProfileId()==profileid){

List<User> UserList=new List<User>([Select Id,Primary_Territory_Vod__c,Name,Email from user where IsActive=true]);
               
        for(User u:UserList){
        
        UserDetailsMap.put(u.Id,u);
        
        UserMap.put(u.Primary_Territory_vod__c,u.Name);
        UserTerrMap.put(u.Primary_Territory_vod__c,u.id);
        UserIdMap.put(u.Primary_Territory_vod__c,u.Email);
        }

for(Account acc:newAccList){
    
   AccountZipSet.add(acc.Primary_Zip__c);
    
}

ZipTerrList=[Select Name,Territory_Vod__c from Zip_To_Terr_vod__c  where Name IN: AccountZipSet];
            
for(Zip_To_Terr_vod__C z: ZipTerrList){

ZipTerrMap.put(z.Name,z.Territory_vod__c);


}
              
 if(checkRecursive.runOnce()) {
            for(Account acc: newAccList){
     
     IF(ZipTerrMap.get(acc.Primary_Zip__c)!=null){
     acc.Rep_Territory__c=ZipTerrMap.get(acc.Primary_Zip__c).substring(0,8);
     acc.Assigned_Rep__c=UserMap.get(acc.Rep_Territory__c);
     acc.Rep_Email__c=UserIdMap.get(ZipTerrMap.get(acc.Primary_Zip__c).substring(0,8));
     
     if(ZipTerrMap.get(acc.Primary_Zip__c).length()>=15){
                acc.MSL_Territory__c=ZipTerrMap.get(acc.Primary_Zip__c).substring(7,15);
                acc.Assigned_MSL__c=UserMap.get(acc.MSL_Territory__c);
                                                                }
     updateAccountList.add(acc);
                                        }
     }

     update updateAccountList;
}

List<Account> updateAccList=new List<Account>();

/*for(Account acc: newAccList){

acc.Assigned_Rep__c=UserMap.get(acc.Rep_Territory__c);
acc.Assigned_MSL__c=UserMap.get(acc.MSL_Territory__c);
acc.Rep_Email__c=UserIdMap.get(ZipTerrMap.get(acc.Primary_Zip__c).substring(0,8));
updateAccList.add(acc);

}
update updateAccList; */

}
  
///To Insert Alerts...
  
List<Alert_vod__c> AlertExistingList=new List<Alert_vod__c>([Select Id,Account__c from Alert_Vod__c]);

for(Alert_vod__c a: AlertExistingList){

AlertAccountIds.add(a.Account__c);

}

for(Account acc:newAccList ){
    
    if(acc.New_RX_Date__c!=null){
AccountMap.put(acc.Id,acc);

    }
}

ExistingAlertList=[Select Id,Account__c from Alert_vod__c];

for(Alert_vod__c a: ExistingAlertList){

AlertMap.put(a.Account__c,a);

}
AlertList=[Select Id,Activation_Date_vod__c,Expiration_Date_vod__c,Link_Reference_vod__c,
           Account__c,New_Prescriber__c,
          Priority_vod__c,Public_vod__c,Dismissible_vod__c,Alert_Text_vod__c,Name,User__c,
          Rep_Email__c,New_Prescription__c
          from Alert_vod__c where 
          Account__c IN: AccountMap.keyset()];
                   
  //Insert updated alerts
  
  List<Alert_vod__c> InsertUpdAlerts=new List<Alert_vod__C>(); 
  

if(Trigger.IsUpdate){

for(Account acc: newAccList){

    if(Trigger.oldMap.get(acc.Id).New_RX_Date__c!=Trigger.newMap.get(acc.Id).New_RX_Date__c){


//for(Alert_vod__c a: AlertList){

//if(AccountMap.get(a.Account__c).New_Prescriber__c=='Yes'){

if(acc.New_Rx_Date__c!=null){

Alert_vod__c a=new Alert_vod__c();
//a.Activation_Date_vod__c=AccountMap.get(a.Account__c).New_Rx_Date__c;
a.Account__c=acc.Id;
a.Activation_Date_vod__c=acc.New_Rx_Date__c;
//a.Expiration_Date_vod__c=AccountMap.get(a.Account__c).New_RX_Alert_Expiration_Date__c;
a.Expiration_Date_vod__c=acc.New_RX_Alert_Expiration_Date__c;

a.public_vod__c=false;
a.alert_text_vod__c='Specialty:' + ' ' +   acc.Specialty_1_vod__c +
                 '\r\n' +
                 + 'Click HCPs link to view additional information';
                 
                 if(acc.New_Prescriber__c=='Yes'){
a.Name='New Prescriber';
a.New_Prescriber__c='Yes';
a.New_Prescription__c='No';

                 }
                 
           if(acc.New_Precription__c=='Yes'){
a.Name='New Prescription';
a.New_Prescription__c='Yes';
a.New_Prescriber__c='No';

                 }
a.Link_Reference_vod__c=acc.Id+','+'Account';
a.Priority_vod__c='Important';
a.Dismissible_vod__c=true;
a.Rep_Email__C=acc.Rep_Email__c;
a.OwnerId=UserTerrMap.get(ZipTerrMap.get(acc.Primary_Zip__c).substring(0,8));

InsertUpdAlerts.add(a);
//}
}
}


}
}    
insert InsertUpdAlerts;

if(Trigger.IsInsert){
   for(Account a: Trigger.new){
   
        if(a.New_RX_Date__c!=null){
   
       if(!AlertAccountIds.contains(a.id)){
       
       Alert_vod__c al=new Alert_vod__c();
       
       al.Account__c=a.id;
       
       al.Activation_Date_vod__c=a.New_Rx_Date__c;
       
       al.Expiration_Date_vod__c=a.New_RX_Alert_Expiration_Date__c;
       
       al.public_vod__c=false;
       
       al.alert_text_vod__c='Specialty:' + ' ' +   a.Specialty_1_vod__c +
                 '\r\n'+
                 + 'Click HCPs link to view additional information';
                 
                 if(a.New_Prescriber__c=='Yes'){
       al.name='New Prescriber';
       al.New_Prescriber__c='Yes';
       al.New_Prescription__c='No';
       
                 }
                 
                 
              if(a.New_Precription__c=='Yes'){
       al.name='New Prescription';
       al.New_Prescription__c='Yes';
       al.New_Prescriber__c='No';
       
                 }   
       
       al.Link_Reference_vod__c=a.Id+',' + 'Account';
       
       al.Priority_vod__c='Important';
     
       
       al.Rep_Email__C=a.Rep_Email__c;
       
       al.Dismissible_vod__c=true;
       
        
       
       al.OwnerId=UserTerrMap.get(ZipTerrMap.get(a.Primary_Zip__c).substring(0,8));
       
       InsertAlertList.add(al);
      }
    }
     }
     insert InsertAlertList;
     }
   }
Hi,

I am trying to maintain count in batch apex. i am using database.stateful.. but the count is not being maintained... below is the code:-

global class Batch_ConvertLead implements Database.Batchable<sObject>, Database.Stateful {

    public String query;
    public String rank = 'Ghost App';
  global integer Count;

    global database.querylocator start(Database.BatchableContext BC){
        query = 'SELECT Id, AccountId__c FROM Lead WHERE isconverted = false AND Rank__c = :rank and AccountId__c != null';
        return Database.getQueryLocator(query); 
 Count=0;
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){

        List<Lead> leadsToConvert = new List<Lead>();
        list<Database.LeadConvert> leadConverts = new list<Database.LeadConvert>();

        for(sObject leadconv : scope){
            leadsToConvert.add((Lead) leadconv);
        } 
    
        for(lead le :leadsToConvert){
        
            for(Integer i=1;i<leadsToConvert.size();i++){
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(le.Id);
            lc.setConvertedStatus('Converted');
            lc.setDoNotCreateOpportunity(true);
            lc.setAccountId(le.AccountId__c);
            leadConverts.add(lc);
            Count = count + 1;
            
            }
        }
        Database.LeadConvertResult[] lcrList = Database.convertLead(leadconverts, true);
        for(Database.LeadConvertResult result : lcrlist) {
            if(!result.isSuccess()) {
                System.debug(result.getErrors());
            }
        }
    }

    global void finish(Database.BatchableContext BC){
        AsyncApexJob asyJob = [SELECT Id,Status,CompletedDate,TotalJobItems, NumberOfErrors, JobItemsProcessed,CreatedBy.Email FROM AsyncApexJob WHERE Id = :BC.getJobId()];
        //String[] toAddresses = new String[] {system.label.Ireland_EmailD_BatchApex}; 
        String[] toAddresses = new String[] {'janardhanan.jagadeesan@hotchalk.com'}; 
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        String subject = 'Lead Convert Batch';
        mail.setSubject(subject+ '<' + asyJob.status + '>');
        mail.setPlainTextBody('The batch Apex job processed ' + asyJob.TotalJobItems + ' batches with a total of ' + count + ' records with '+ asyJob.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
    }

}

 
Hi, 

I am adding getting following error while adding the elements to a map. 

Error:- Incompatible value type Object for Map

Code:-

public class CR_Report{

public void Completed_CR_Report(){
     
         //Compare old zip  on account with the new zip.. if it is different insert the record into
         // CR_Audit_Move__c
         
         
      List<Change_Request_MDV__c> CRCompletedList=new List<Change_Request_MDV__c>([Select Account__c,Name,Status__C,Reason__c,
                                                                                   New_Territory__c,Zip_MDVN__c, State_MDVN__c,CreatedDate,LastModifiedDate
                                                                                from Change_Request_MDV__c
                                                                                where Status__C='On Hold'
                                                                                and Reason__c in ('Completed')
                                                                                and LastModifiedDate=Today]);
      
     Map<String,String> AccCRMap=new Map<String,String>(); 
      
      for(Change_Request_MDV__c c: CRCompletedList){
          
          AccCRMap.put(c.Account__c,c.Id);
          
          
      }
     
      List<Account> AccCRList=new List<Account>([Select Id from Account
                                                 where ID IN:AccCrMap.keyset()]);
                                                 
      Map<String,String> OldAccMap=new Map<String,String>();
      
      Map<String,String> NewAccMap=new Map<String,String>();
      
      List<AccountHistory> AccHistoryList=new List<AccountHistory>([Select AccountId,oldvalue,newvalue from 
                                                                     AccountHistory
                                                                     where field='Territory_vod__c'
                                                                     and AccountId IN:AccCrMap.keyset()]);
                                                                     
         for(AccountHistory ah:AccHistoryList){
             
             oldAccMap.put(ah.AccountId,ah.oldvalue);//>>>>>>>>>>>>>>>> Error Line<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
             
             //NewAccMap.put(ah.AccountId,ah.newvalue);
             
             
         }                                                                
                                                                                                                
      
      
     
     
     
     }


}
Hi,

I am looking to identify salesforce records which were modified in the last 2 hours based on lastmodifeddate. Is there a datetime filter which can be used in SOQL to acheive this.
Hi, 

I am facing the below error message while extracting data using data loader CLI:

ApiFault  exceptionCode='MALFORMED_QUERY'  
Bind variables only allowed in Apex code

Full SOQL being used:- 

SOQL="Select Id, IsDeleted, MasterRecordId, Name, LastName, FirstName, Salutation, RecordTypeId, IsPersonAccount, PersonTitle, PersonBirthdate, MDVN_MDV__c, Credentials_vod__c, Specialty_1_vod__c, Specialty_2_vod__c, Gender_vod__c, PDRP_Opt_Out_vod__c, PDRP_Opt_Out_Date_vod__c, Middle_vod__c, Suffix_vod__c, NPI_vod__c, ME__c, Account_Type__c, WK_MDV__c,mCRPC_Treatment_MDVN__c,Phone, Fax, PersonEmail, EDSE_Person_Has_Opted_In__c, Target__c,Pending_Validation_MDV__c,POA_Target_MDV__c,Role_MDVN__c FROM Account where LastModifiedDate > "

Below is the entire error message:- 

2015-01-31 11:06:27,474 INFO  [main] controller.Controller initLog (Controller.java:404) - The log has been initialized
2015-01-31 11:07:18,227 INFO  [main] controller.Controller initConfig (Controller.java:365) - The controller config has been initialized
2015-01-31 11:07:18,234 INFO  [main] process.ProcessRunner run (ProcessRunner.java:116) - Initializing process engine
2015-01-31 11:07:18,236 INFO  [main] process.ProcessRunner run (ProcessRunner.java:119) - Loading parameters
2015-01-31 11:07:18,238 INFO  [main] config.LastRun load (LastRun.java:96) - Last run info will be saved in file: C:\apexdataloader\conf\null_lastRun.properties
2015-01-31 11:07:18,372 INFO  [main] process.ProcessRunner run (ProcessRunner.java:127) - Logging in to: https://login.salesforce.com
2015-01-31 11:07:18,439 INFO  [main] client.PartnerClient login (PartnerClient.java:478) - Beginning Partner Salesforce login ....
2015-01-31 11:07:18,539 INFO  [main] client.PartnerClient loginInternal (PartnerClient.java:519) - Salesforce login to https://login.salesforce.com/services/Soap/u/24.0 as user data@medivation.com
2015-01-31 11:07:20,146 INFO  [main] dao.DataAccessObjectFactory getDaoInstance (DataAccessObjectFactory.java:51) - Instantiating data access object: C:\apexdataloader\temp\med_inq_201501311102.csv of type: csvWrite
2015-01-31 11:07:20,157 INFO  [main] process.ProcessRunner run (ProcessRunner.java:132) - Checking the data access object connection
2015-01-31 11:07:20,192 INFO  [main] process.ProcessRunner run (ProcessRunner.java:137) - Setting field types
2015-01-31 11:07:20,820 INFO  [main] process.ProcessRunner run (ProcessRunner.java:141) - Setting object reference types
2015-01-31 11:07:22,023 INFO  [main] process.ProcessRunner run (ProcessRunner.java:145) - Creating Map
2015-01-31 11:07:22,094 INFO  [main] action.OperationInfo instantiateAction (OperationInfo.java:95) - Instantiating action for operation: extract
2015-01-31 11:07:22,129 INFO  [main] controller.Controller executeAction (Controller.java:123) - executing operation: extract
2015-01-31 11:07:22,129 INFO  [main] action.AbstractAction execute (AbstractAction.java:115) - Loading: extract
2015-01-31 11:07:23,742 ERROR [main] client.PartnerClient runOperation (PartnerClient.java:332) - Error while calling web service operation: query, error was: 
[MalformedQueryFault [ApiQueryFault [ApiFault  exceptionCode='MALFORMED_QUERY'
 exceptionMessage='
in('Yes') and LastModifiedDate >Sqlcmd:
                               ^
ERROR at Row:1:Column:817
Bind variables only allowed in Apex code'
]
 row='1'
 column='817'
]
]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:627)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504)
    at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:229)
    at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:203)
    at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:149)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:98)
    at com.sforce.soap.partner.PartnerConnection.query(PartnerConnection.java:1334)
    at com.salesforce.dataloader.client.PartnerClient$5.run(PartnerClient.java:124)
    at com.salesforce.dataloader.client.PartnerClient$5.run(PartnerClient.java:116)
    at com.salesforce.dataloader.client.PartnerClient.runOperation(PartnerClient.java:328)
    at com.salesforce.dataloader.client.PartnerClient.query(PartnerClient.java:392)
    at com.salesforce.dataloader.action.visitor.PartnerQueryVisitor.getQueryResult(PartnerQueryVisitor.java:65)
    at com.salesforce.dataloader.action.visitor.PartnerQueryVisitor.executeQuery(PartnerQueryVisitor.java:60)
    at com.salesforce.dataloader.action.visitor.AbstractQueryVisitor.visit(AbstractQueryVisitor.java:70)
    at com.salesforce.dataloader.action.AbstractExtractAction.visit(AbstractExtractAction.java:57)
    at com.salesforce.dataloader.action.AbstractAction.execute(AbstractAction.java:125)
    at com.salesforce.dataloader.controller.Controller.executeAction(Controller.java:124)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:149)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
2015-01-31 11:07:23,751 ERROR [main] action.AbstractAction handleException (AbstractAction.java:200) - Exception occured during loading
com.salesforce.dataloader.exception.ExtractException: 
in('Yes') and LastModifiedDate >Sqlcmd:
                               ^
ERROR at Row:1:Column:817
Bind variables only allowed in Apex code
    at com.salesforce.dataloader.action.visitor.AbstractQueryVisitor.visit(AbstractQueryVisitor.java:80)
    at com.salesforce.dataloader.action.AbstractExtractAction.visit(AbstractExtractAction.java:57)
    at com.salesforce.dataloader.action.AbstractAction.execute(AbstractAction.java:125)
    at com.salesforce.dataloader.controller.Controller.executeAction(Controller.java:124)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:149)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
Caused by: [MalformedQueryFault [ApiQueryFault [ApiFault  exceptionCode='MALFORMED_QUERY'
 exceptionMessage='
in('Yes') and LastModifiedDate >Sqlcmd:
                               ^
ERROR at Row:1:Column:817
Bind variables only allowed in Apex code'
]
 row='1'
 column='817'
]
]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:627)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504)
    at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:229)
    at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:203)
    at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:149)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:98)
    at com.sforce.soap.partner.PartnerConnection.query(PartnerConnection.java:1334)
    at com.salesforce.dataloader.client.PartnerClient$5.run(PartnerClient.java:124)
    at com.salesforce.dataloader.client.PartnerClient$5.run(PartnerClient.java:116)
    at com.salesforce.dataloader.client.PartnerClient.runOperation(PartnerClient.java:328)
    at com.salesforce.dataloader.client.PartnerClient.query(PartnerClient.java:392)
    at com.salesforce.dataloader.action.visitor.PartnerQueryVisitor.getQueryResult(PartnerQueryVisitor.java:65)
    at com.salesforce.dataloader.action.visitor.PartnerQueryVisitor.executeQuery(PartnerQueryVisitor.java:60)
    at com.salesforce.dataloader.action.visitor.AbstractQueryVisitor.visit(AbstractQueryVisitor.java:70)
    ... 6 more
2015-01-31 11:07:23,755 ERROR [main] progress.NihilistProgressAdapter doneError (NihilistProgressAdapter.java:58) - 
in('Yes') and LastModifiedDate >Sqlcmd:
                               ^
ERROR at Row:1:Column:817
Bind variables only allowed in Apex code

 
Hi, 

I am adding getting following error while adding the elements to a map. 

Error:- Incompatible value type Object for Map

Code:-

public class CR_Report{

public void Completed_CR_Report(){
     
         //Compare old zip  on account with the new zip.. if it is different insert the record into
         // CR_Audit_Move__c
         
         
      List<Change_Request_MDV__c> CRCompletedList=new List<Change_Request_MDV__c>([Select Account__c,Name,Status__C,Reason__c,
                                                                                   New_Territory__c,Zip_MDVN__c, State_MDVN__c,CreatedDate,LastModifiedDate
                                                                                from Change_Request_MDV__c
                                                                                where Status__C='On Hold'
                                                                                and Reason__c in ('Completed')
                                                                                and LastModifiedDate=Today]);
      
     Map<String,String> AccCRMap=new Map<String,String>(); 
      
      for(Change_Request_MDV__c c: CRCompletedList){
          
          AccCRMap.put(c.Account__c,c.Id);
          
          
      }
     
      List<Account> AccCRList=new List<Account>([Select Id from Account
                                                 where ID IN:AccCrMap.keyset()]);
                                                 
      Map<String,String> OldAccMap=new Map<String,String>();
      
      Map<String,String> NewAccMap=new Map<String,String>();
      
      List<AccountHistory> AccHistoryList=new List<AccountHistory>([Select AccountId,oldvalue,newvalue from 
                                                                     AccountHistory
                                                                     where field='Territory_vod__c'
                                                                     and AccountId IN:AccCrMap.keyset()]);
                                                                     
         for(AccountHistory ah:AccHistoryList){
             
             oldAccMap.put(ah.AccountId,ah.oldvalue);//>>>>>>>>>>>>>>>> Error Line<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
             
             //NewAccMap.put(ah.AccountId,ah.newvalue);
             
             
         }                                                                
                                                                                                                
      
      
     
     
     
     }


}
Hi,

I am looking to identify salesforce records which were modified in the last 2 hours based on lastmodifeddate. Is there a datetime filter which can be used in SOQL to acheive this.