• Anna Miller
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have the following code in a class below:

User u = [SELECT RepName__c FROM User WHERE Id = :UserInfo.getUserId()];
        List<String> zipcodes = new List<String>();
        //create map to track updated zips within execution context
        Map<Id,Zip_Code_Availability__c> zipToUpdate = new Map<Id,Zip_Code_Availability__c>();
        for(Zip_Code_Availability__c z :newlist) {
            if(newmap.get(z.id).Lock_Zip__c == 'Lock' && oldmap.get(z.id).Lock_Zip__c !='Lock' && !zipToUpdate.containskey(z.Id)) {
                z.CalloutPending__c = true;
                z.Lock_Zip_Requested_By__c = u.RepName__c;
                z.Lock_Zip_Date_Time__c = datetime.now();
                zipToUpdate.put(z.Id,z);
            } else {
            [...]
            }
       }

For some reason when I do a mass update with dataloader (I've tested with 1000+ records), datetime.now() populates with a random datetime sometimes in the past sometimes in the future, but different for all records.  Also, the User returned with the soql query in the top row is not myself even though I'm logged into DataLoader.  

Any ideas as to why it would do this? Let me know if you need me to post the whole code for context.  Thanks for any help you can offer. 
I have the following code in a class below:

User u = [SELECT RepName__c FROM User WHERE Id = :UserInfo.getUserId()];
        List<String> zipcodes = new List<String>();
        //create map to track updated zips within execution context
        Map<Id,Zip_Code_Availability__c> zipToUpdate = new Map<Id,Zip_Code_Availability__c>();
        for(Zip_Code_Availability__c z :newlist) {
            if(newmap.get(z.id).Lock_Zip__c == 'Lock' && oldmap.get(z.id).Lock_Zip__c !='Lock' && !zipToUpdate.containskey(z.Id)) {
                z.CalloutPending__c = true;
                z.Lock_Zip_Requested_By__c = u.RepName__c;
                z.Lock_Zip_Date_Time__c = datetime.now();
                zipToUpdate.put(z.Id,z);
            } else {
            [...]
            }
       }

For some reason when I do a mass update with dataloader (I've tested with 1000+ records), datetime.now() populates with a random datetime sometimes in the past sometimes in the future, but different for all records.  Also, the User returned with the soql query in the top row is not myself even though I'm logged into DataLoader.  

Any ideas as to why it would do this? Let me know if you need me to post the whole code for context.  Thanks for any help you can offer.