You need to sign in to do that
Don't have an account?
SFDC 2017
Want to know about dynamic Apex code to be used in Batch Apex
Hi All, I used batch Apex normally but using dynamic apex i am new.Can anyone please guide me for the Following Scenario using Batch Apex(Dynamic)
In Batch Class constructor: global Account batch(String ObjectName)
My scenario i passed this ObjectName as parameter and
if (ObjectName==Account)
{ need to query account records
}
else if (ObjectName =Contact )
{ Query Contact records)
}
So i will get either account or contact records in scope and in execute method i will create records for other custom object based on this scope And in scheduler class how i will pass for account and contact
Please anyone guide me to do this
Thanks in advance
In Batch Class constructor: global Account batch(String ObjectName)
My scenario i passed this ObjectName as parameter and
if (ObjectName==Account)
{ need to query account records
}
else if (ObjectName =Contact )
{ Query Contact records)
}
So i will get either account or contact records in scope and in execute method i will create records for other custom object based on this scope And in scheduler class how i will pass for account and contact
Please anyone guide me to do this
Thanks in advance
If this answer helps you, please mark this as a solution to help the community get solutions; quicker.
Thanks
Santosh Kumar Sriram
If you think this helped you, please mark this as an answer!
Thanks
Santosh Kumar Sriram
One more error when running test class it is showing error as Error MessageSystem.QueryException: unexpected token: <EOF>
Stack TraceClass.ClassbatchInsert.start: line 32, column 1. return Database.getQueryLocator(query);this is 32 line.
query = 'Select Id,CreatedDate FROM Account WHERE CreatedById =:UserId AND Account_Id__c = NULL';
what is the problem here?