调用保存服务报错:索引超出
金蝶云社区-孙艳明_1
孙艳明_1
0人赞赏了该文章 1,344次浏览 未经作者许可,禁止转载编辑于2017年08月07日 18:32:55

基本需求: 自定义bos单据,自增按钮 点击按钮后调用 生产领料单的保存服务,

以上调用保存服务报错 红的 部分

OperateOption saveOption = OperateOption.Create();
var bussnessInfo = Kingdee.BOS.ServiceHelper.MetaDataServiceHelper.GetFormMetaData(this.Context, "PRD_PickMtrl").BusinessInfo;
var billDynamicObjectType = bussnessInfo.GetDynamicObjectType();
DynamicObject billobj = new DynamicObject(billDynamicObjectType);
//生产组织

//获取生产组织数据包
DynamicObject[] objSCZZ = BusinessDataServiceHelper.Load(
this.Context,
new object[] { 1 },
(MetaDataServiceHelper.Load(this.Context, "ORG_ORGANIZATIONS") as FormMetadata).
BusinessInfo.GetDynamicObjectType());
billobj["PRDORGID_ID"] = 1;
billobj["PRDORGID"] = objSCZZ[0];
//获取发料组织数据包
DynamicObject[] objFLZZ = BusinessDataServiceHelper.Load(
this.Context,
new object[] { 1 },
(MetaDataServiceHelper.Load(this.Context, "ORG_ORGANIZATIONS") as FormMetadata).
BusinessInfo.GetDynamicObjectType());
billobj["StockOrgId_ID"] = 1;
billobj["StockOrgId"] = objFLZZ[0];

//单据时间
billobj["Date"] = DateTime.Now;
单据类型
DynamicObject[] objbilltype = BusinessDataServiceHelper.Load(
this.Context,
new object[] { "123f39178eb2424c8449f992e1fff1ee" },
(MetaDataServiceHelper.Load(this.Context, "BOS_BILLTYPE") as FormMetadata).
BusinessInfo.GetDynamicObjectType());
billobj["BillType_ID"] = "123f39178eb2424c8449f992e1fff1ee";
billobj["BillType"] = objbilltype[0];

IOperationResult RS = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Save(this.Context, bussnessInfo, billobj);
// this.View.ShowMessage( RS.OperateResult)
if (RS.IsSuccess == false)
{
string rs = string.Empty;
foreach (var a in RS.ValidationErrors)
{
rs= a.Message+" ;"+rs;
}
this.View.ShowMessage(rs);
}

以上只是构建了一个字段的数据包,而且一个一个构建很麻烦,有没有简便方法???