You need to sign in to do that
Don't have an account?
Insert Opportunity with Opportunity Line Item in the same batch
I try to insertt some Opportunity with their Opportunity Line Items.
Database.insert(OppBillingList.Values()); List<OpportunityLineItem> Olichildren = new List<OpportunityLineItem>(); for(String oppkey : OliBillingMap.keySet()){ system.debug('oppkey :'+oppkey); for(string oliMAPID :OppBillingList.keySet() ){ system.debug('oliMAPID :'+oliMAPID); if(oppkey==oliMAPID ) { system.debug('ID match : ' + oliMAPID); Id parentId = OppBillingList.get(oppkey).Id; // grab the salesforce id, now that Opportunity has been inserted list<OpportunityLineItem> lineToAdd = new list<OpportunityLineItem>(); lineToAdd= OliBillingMap.get(oliMAPID) ; system.debug('lineToAdd :' + lineToAdd.size()); for(OpportunityLineItem oli : lineToAdd) { oli.OpportunityId = parentId; Olichildren.add(oli); } } } } insert Olichildren ;
when I execute that code in Exclipse I get the following error Message :
eclipse.buildId=M20100211-1343
java.version=1.6.0_29
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=en_US
Framework arguments: -keyring /Users/marcbazin/.eclipse_keyring -showlocation
Command-line arguments: -os macosx -ws cocoa -arch x86 -keyring /Users/marcbazin/.eclipse_keyring -showlocation
Error
Tue Jan 17 01:44:06 CET 2012
An internal error occurred during: "Execute-Anonymous".
java.lang.NullPointerException
at com.salesforce.ide.core.internal.utils.ForceExceptionUtils.getConnectionCauseExceptionMessage(ForceExceptionUtils.java:98)
at com.salesforce.ide.core.services.ApexService.errorExecuteAnonymousResult(ApexService.java:88)
at com.salesforce.ide.core.services.ApexService.executeAnonymous(ApexService.java:41)
at com.salesforce.ide.core.services.ApexService$$FastClassByCGLIB$$5932a7ac.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.salesforce.ide.core.services.ApexService$$EnhancerByCGLIB$$84e18137.executeAnonymous(<generated>)
at com.salesforce.ide.ui.views.executeanonymous.ExecuteAnonymousController.executeExecuteAnonymous(ExecuteAnonymousController.java:28)
at com.salesforce.ide.ui.views.executeanonymous.ExecuteAnonymousViewComposite$4.runInWorkspace(ExecuteAnonymousViewComposite.java:161)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
What should I do to insert the Line Items directly in the same batch ?