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

batch is not inserting record
Hello All,
I am querying record from one object and inserting to the other object but record is not getting inserted into another object. Can someone help me pls. Thanks
here is my code:
I am querying record from one object and inserting to the other object but record is not getting inserted into another object. Can someone help me pls. Thanks
here is my code:
global class FileImpoLog implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext bc){ date d=system.today(); return Database.getQueryLocator([Select Document_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById from Importer_Submit__c ]); } global void execute(Database.BatchableContext BC, list<Importer_Submit__c> lstFileImpor){ system.debug('lstFileImpor******' + lstFileImpor); List<Importer_Log_Entry__c> lstLogEntry = new List<Importer_Log_Entry__c>(); for(Importer_Submit__c M : lstFileImpor){ Importer_Log_Entry__c ML = new Importer_Log_Entry__c(); ML.created_by__c = string.valueof(M.CreatedBy); ML.Document_Process_Date__c = M.Document_Process_Date__c; ML.Workspace_Id__c = M.Workspace__c; ML.Workspace_Name__c = M.Folder_Name__c; ML.Created_Date__c = M.CreatedDate; lstLogEntry.add(ML); } system.debug('lstLogEntry*******' + lstLogEntry); insert lstLogEntry; } global void finish(Database.BatchableContext BC){ } }
Hello,
The error was here
return Database.getQueryLocator([SelectDocument_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById fromImporter_Submit__c ]);
Instead we need to pass the query in string
somthing like : query = 'SelectDocument_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById fromImporter_Submit__c '
All Answers
Check below point
Yes I am inserting all the required fields and I am not seeing the debug in the debug log.
Debug is not available in the log.
SelectDocument_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById fromImporter_Submit__c
Set logs like this
From Setup, enter Debug Logs in the Quick Find box, then click Debug Logs.
Click New.
Set the traced entity type to User.
Open the lookup for the Traced Entity Name field, and then find and select your guest user.
Assign a debug level to your trace flag.
Click Save.
Hello,
The error was here
return Database.getQueryLocator([SelectDocument_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById fromImporter_Submit__c ]);
Instead we need to pass the query in string
somthing like : query = 'SelectDocument_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById fromImporter_Submit__c '