You need to sign in to do that
Don't have an account?
Tarun Kaushik
Getting start with salesforce
Hi All
Newbie... so please be gentle.
Trying to learn coding by wrtiig classes with small scenarios in salesforce.
I have a custome object which have mendatory fields and Id of its records in a custome field,I want to create new opportunity records through a apex bacth class which will run daily and create all the new records from the custom objects.
What can be basic approach to start coding for this class.
Newbie... so please be gentle.
Trying to learn coding by wrtiig classes with small scenarios in salesforce.
I have a custome object which have mendatory fields and Id of its records in a custome field,I want to create new opportunity records through a apex bacth class which will run daily and create all the new records from the custom objects.
What can be basic approach to start coding for this class.
Is there any reason you want to do this as a batch instead of a trigger when the object is created?
[1] http://blog.deadlypenguin.com/blog/2012/05/26/scheduled-actions-in-salesforce-with-apex/
[2] https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
[3] https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
[4] https://github.com/zachelrath/Relax
I have written the below class for creating new opportunity can you please help to write the trigger which can be used to insert opprtunity records from my custom object
Nextgen__c -custom objects which contains all menadatory fields to create a new oppty
public class Create_oppty{
List<Nextgen__c> Nextgenlist = new List<Nextgen__c>();
public Create_oppty(){
Nextgenlist = [select Name,Close_Date__c,Record_Id__c,Stage__c from Nextgen__c];
system.debug(Nextgenlist);
}
public Void InsertOppty(){
List<Opportunity> Opptylist = new List<Opportunity>();
for(Nextgen__c obj:Nextgenlist){
Opportunity objOpp=new Opportunity();
objOpp.Name=obj.Name;
objOpp.CloseDate=obj.Close_Date__c;
objOpp.StageName=obj.Stage__c;
Opptylist.add(objOpp);
}
if (Opptylist.size()>0) {
Insert Opptylist;
}
}
}
This will create a new Opportunity for each Nextgen that is created.