开发者

Error while creating a new "OpportunityLineItemSchedule" using SFDC Partner API

When I try to create a new OpportunityLineItemSchedule I'm running into 开发者_Go百科following error..

Error code: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

Error message: insufficient access rights on cross-reference id

Attached is the code snippet. Any help will be extremely useful.

SObject[] rs = new SObject[1];
MessageElement[] specificRS = new MessageElement[6];
specificRS[0] = new MessageElement(new QName("OpportunityLineItemId"),"00k7000000DFLqfAAH");
specificRS[1] = new MessageElement(new QName("Description"),"Rev Schedule Descr");
specificRS[2] = new MessageElement(new QName("Type"),"Quantity"); 
specificRS[3] = new MessageElement(new QName("Quantity"),(double)2);
specificRS[4] = new MessageElement(new QName("Revenue"),(double)400000.00);
specificRS[5] = new MessageElement(new QName("ScheduleDate"),"2010-10-30");

rs[0] = new SObject();
rs[0].setType("OpportunityLineItemSchedule");
rs[0].set_any(specificRS);

SaveResult[] sr = null;
try {
  sr = binding.create(rs);
} catch (Exception ex) {
  System.out.println("An unexpected error has occurred." + ex.getMessage());
  ex.printStackTrace();
  return;
}


Following works..

    MessageElement[] specificRS2 = new MessageElement[5];
specificRS2[0] = new MessageElement(new QName("OpportunityLineItemId"),"00k7000000DFcOG");
// PricebookEntryId can be found by joining PricebookEntry and Pricebook2 tables (on Product2Id and 
specificRS2[1] = new MessageElement(new QName("Description"),"Rev Schedule Descr2");
specificRS2[2] = new MessageElement(new QName("ScheduleDate"),"2010-10-31");
//specificRS[3] = new MessageElement(new QName("Quantity"),(double)2);
specificRS2[3] = new MessageElement(new QName("Revenue"),(double)10.00);
//specificRS[4] = new MessageElement(new QName("Type"),"Quantity"); // and/or "Revenue"
specificRS2[4] = new MessageElement(new QName("Type"),"Revenue"); // and/or "Quantity"

rs[1] = new SObject();
rs[1].setType("OpportunityLineItemSchedule");
rs[1].set_any(specificRS2);

SaveResult[] sr = null;
try {
  sr = binding.create(rs);
} catch (Exception ex) {
  System.out.println("An unexpected error has occurred." + ex.getMessage());
  ex.printStackTrace();
  return;
}


This is usually an error when code is trying to use an ID for an object that doesn't exist, or that the user doesn't have access to. I take it the only difference between the 2 snippets is the OpportunityLineItem ID? Check that the user running the code can access the item with that ID.


Have a look at the Allowed Type Field Values and Allowed Quantity and Revenue Field Values documentation for OpportunityLineItemSchedule.

The allowed Type values for an OpportunityLineItemSchedule depend on the product-level schedule preferences and whether the line item has any existing schedules

You may need to check if there are existing OpportunityLineItemSchedule records.

The allowable Quantity and Revenue field values depend on the value of the Type field

You only set the Quantity or Revenue field, not both.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜