插件保存单据时,单据体字段保存不到数据库
金蝶云社区-Sicker666
Sicker666
0人赞赏了该文章 771次浏览 未经作者许可,禁止转载编辑于2018年12月20日 11:25:28

问题详情:通过向目标单据体数据包填充数据后,保存单据。通过跟踪可以看到目标单据体内容已经填充成功,但是执行保存时,单据体的对应数据表内只有FID和FENTRYID正常有值,但是其它字段全是未写入。目标单据体为上级单据复制出来的,所有字段(标识,字段名,ORM实体名)都是一样的
代码如下:
[code]
DynamicObject sObj = this.Model.DataObject;
#region 下达设计目标成本单
FormMetadata meta = MetaDataServiceHelper.Load(this.Context, "kb7bb7976cff545dca7bd785057095d5e") as FormMetadata;
DynamicObject billObj = new DynamicObject(meta.BusinessInfo.GetDynamicObjectType());
billObj["FFormId"] = "kb7bb7976cff545dca7bd785057095d5e";
billObj["FProjectNo"] = sObj["BillNo"];
billObj["ProjectName"] = sObj["ProjectName"];
billObj["ProductName"] = sObj["ProductName"];
billObj["Power"] = sObj["Power"];
billObj["DesignWeight"] = sObj["DesignWeight"];
billObj["CreatorId_Id"] = this.Context.UserId;
billObj["CreateDate"] = DateTime.Now.ToString("yyyy-MM-dd");
billObj["ProductModel"] = sObj["ProductModel"];
billObj["F_CS_OrgId_Id"] = sObj["F_CS_OrgId_Id"];
billObj["F_CS_OrgId"] = sObj["F_CS_OrgId"];
billObj["Cust_Id"] = sObj["Cust_Id"];
billObj["Cust"] = sObj["Cust"];
billObj["FDeptID_Id"] = 122237;
billObj["DocumentStatus"] = "A";

//方案设计人赋值
MulBaseDataField FDesign = meta.BusinessInfo.GetField("FDesign") as MulBaseDataField;
DynamicObjectCollection tDesign = billObj["Design"] as DynamicObjectCollection;
DynamicObjectCollection sDesign = sObj["Design"] as DynamicObjectCollection;
IViewService viewService = Kingdee.BOS.Contracts.ServiceFactory.GetService(this.Context);
foreach (var Item in sDesign)
{
DynamicObject userRow = new DynamicObject(FDesign.RefEntityDynamicObjectType);
tDesign.Add(userRow);

long designID = Convert.ToInt64(Item["Design_Id"]);
DynamicObject[] designObjs = viewService.LoadFromCache(this.Context,
new object[] { designID }, FDesign.RefFormDynamicObjectType);

FDesign.RefIDDynamicProperty.SetValue(userRow, designID);
FDesign.DynamicProperty.SetValue(userRow, designObjs[0]);
}
//材料清单单据体赋值
DynamicObjectCollection tEntryML = billObj["DTCOrderML"] as DynamicObjectCollection; //目标单据体
DynamicObjectCollection sEntryML = sObj["TCOrderML"] as DynamicObjectCollection; //上级单据体数据
foreach (var Item in sEntryML)
{
var IDS = Kingdee.BOS.ServiceHelper.DBServiceHelper.GetSequenceInt64(this.Context, "CS_T_DTCOrderML", 1);
long entryID = IDS.ElementAt(0);
Item["Id"] = entryID;
tEntryML.Add(Item);
}
var result = BusinessDataServiceHelper.Save(this.Context, meta.BusinessInfo, billObj, OperateOption.Create(), "Save");[/code]请大神帮忙看下代码有无问题?