function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CaptaConsultingCaptaConsulting 

How to create an OpportunityLineItem using javascript and manage the errors

Hi, i am a spanish developer and i am
trying to create an OpportunityLineItem using javascript,

but i have an error:

"One of the records in the batch call resulted in an error.
Examine the records to determine which one(s) failed".

How can i know what record failed??

A snippet of the code is:

var newCItems = new Array(1);
newCItems[0] = sfdc.CreateObject("OpportunityLineItem");
var e2 = new Enumerator(newCItems);
var sobj2 = e2.item();

sobj2.item('PricebookEntryId').value = Id
sobj2.item('Quantity').value = cantidad
sobj2.item('UnitPrice').value = precioUnitario
sobj2.item('OpportunityId').value = "{!Opportunity_ID}";

newCItems[0] = sobj2;
sfdc.Create(newCItems,false);

Someone can help me??

Thanks.