function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public class InsertObj implements Database.Batchable<sObject>, Database.Stateful { public Database.QueryLocator start(Database.BatchableContext bc) { return Database.getQueryLocator( 'SELECT ID,name,stagename from opportunity LIMIT 100' ); } public void execute(Database.BatchableContext bc, List<opportunity> scope){ List<CustomObj__c> objList= new List<CustomObj__c>(); for (opportunity opp: scope) { CustomObj__c obj = new CustomObj__c(); obj.name=opp.name; obj.oppId__c=opp.id; objList.add(obj); } if(objList.size()>0){ insert objList; } } public void finish(Database.BatchableContext bc){ } }
Database.executeBatch(new InsertObj, 20);
Batch class:-
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
create a batch class to insert PIET records from each opportunity in the system??
error in this line
You can create the lookup field (field name->oppId ) relationship with opportunity inside the piet object .
Thanks