单据体新增行,无法保存辅助属性
金蝶云社区-Flong
Flong
0人赞赏了该文章 2,968次浏览 未经作者许可,禁止转载编辑于2016年11月11日 01:49:23


在物料清单中,我新增了一行,修改了辅助属性值后,调用保存方法 BatchSaveEntityFlexObject,但返回ID仍为0.

请各位看一下是哪里出的问题? 谢谢

[code]
DynamicObject newAuxObj = new DynamicObject(auxProp.DynamicObjectType); //
//newAuxObj["F100001_id"] = value;
//newAuxObj["F100501_id"] = valueColor;
//newAuxObj["F100502_id"] = valueState;

DynamicObject newEntryRow = (DynamicObject)entityRows[i].Clone(false, true);


newEntryRow["AuxPropId_ID"] = auxpropid;
newEntryRow["AuxPropId"] = newAuxObj;
newEntryRow["ReplaceGroup"] = replaceGroup;
newEntryRow["MATERIALTYPE"] = 3;
newEntryRow["ParentRowId"] = newEntryRow["RowId"].ToString();
newEntryRow["RowId"] = Guid.NewGuid().ToString();
newEntryRow["EntryRowId"] = newrow;
newEntryRow["ReplacePolicy"] = 1; //策略
newEntryRow["ReplaceType"] = 1; //替代方式
newEntryRow["ReplacePriority"] = Priority; //替代优先级
newEntryRow["MRPPriority"] = Priority; //动态优先级
newEntryRow["IskeyItem"] = 1; //替代主料
newEntryRow["IsCanChoose"] = 0; //可选择
newEntryRow["IsCanEdit"] = 0; //可修改
newEntryRow["IsCanReplace"] = 0; //可替换
newEntryRow["EFFECTDATE"] = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //生效时间

this.Model.CreateNewEntryRow(entity, newrow - 1, newEntryRow);

//如果辅助属性ID为空 ,需要新增数据
if (auxpropid == 0)
{

// DynamicObject newAuxObj = (DynamicObject)entityRows[i]["AuxPropId"]; //
newAuxObj["F100001_id"] = value;
newAuxObj["F100501_id"] = valueColor;
newAuxObj["F100502_id"] = valueState;
newEntryRow["AuxPropId"] = newAuxObj;
// 调用辅助属性保存服务:处理规则和框架一致
FlexSaveService flexSave = new FlexSaveService(this.Context, "ENG_BOM"); //单据唯一标识
flexSave.BatchSaveEntityFlexObject(this.View.BusinessInfo, this.View.BusinessInfo.GetEntity("FTreeEntity"), new DynamicObject[] { billObj });

// 获取辅助属性ID
auxpropid = FlexServiceHelper.GetFlexDataId(this.Context, newAuxObj, FormIdConst.BD_FLEXSITEMDETAILV);
newAuxObj["id"] = auxpropid;

}

newEntryRow["AuxPropId_ID"] = auxpropid;
this.View.Model.SetItemValueByID("FAuxPropId", auxpropid, newrow - 1);[/code]