使用SFDC Partner API创建新的“OpportunityLineItemSchedule”时出错

时间:2010-10-31 18:02:53

标签: java salesforce

当我尝试创建新的OpportunityLineItemSchedule时,我遇到了以下错误。

错误代码:INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

错误消息:交叉引用ID

的访问权限不足

附件是代码段。任何帮助都非常有用。

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;
}

3 个答案:

答案 0 :(得分:0)

以下作品..

    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;
}

答案 1 :(得分:0)

当代码尝试将ID用于不存在的对象或用户无权访问时,通常会出现错误。我认为2个片段之间的唯一区别是OpportunityLineItem ID?检查运行代码的用户是否可以访问具有该ID的项目。

答案 2 :(得分:0)

查看OpportunityLineItemSchedule的Allowed Type Field ValuesAllowed Quantity and Revenue Field Values文档。

  

OpportunityLineItemSchedule的允许类型值取决于产品级计划首选项以及订单项是否包含任何现有计划

您可能需要检查是否存在OpportunityLineItemSchedule记录。

  

允许的“数量”和“收入”字段值取决于“类型”字段的值

您只需设置数量或收入字段,而不是两者。