创建物料的DynamicObject数据包并保存
下面的代码演示了如何在表单插件创建一个新物料,并保存。
/// <summary> /// 创建DynamicOjbect数据包并保存 /// </summary> private void SaveMaterial() { var materailMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, "BD_MATERIAL"); DynamicObject dynObj = new DynamicObject(materailMetadata.BusinessInfo.GetDynamicObjectType()); dynObj["Number"] = "materail01"; dynObj["Name"] = new LocaleValue("物料名称01"); dynObj["DocumentStatus"] = "A";// 数据状态 dynObj["ForbidStatus"] = "A";// 禁用状态 SetBasedataValue(materailMetadata.BusinessInfo, "FBaseUnitId", dynObj, 10087);//基本单位 SetBasedataValue(materailMetadata.BusinessInfo, "FCreateOrgId", dynObj, 100001);//创建组织 SetBasedataValue(materailMetadata.BusinessInfo, "FUseOrgId", dynObj, 100001);//使用组织 SetBasedataValue(materailMetadata.BusinessInfo, "FCreatorId", dynObj, 16394);//创建人 SetBasedataValue(materailMetadata.BusinessInfo, "FModifierId", dynObj, 16394);//修改人 var now = TimeServiceHelper.GetSystemDateTime(this.Context); dynObj["CreateDate"] = now;// 创建时间 dynObj["ModifyDate"] = now;// 修改时间 BusinessDataServiceHelper.Save(this.Context, dynObj); } /// <summary> /// 设置基础资料字段 /// </summary> /// <param name="baseDataFieldKey">基础资料字段Key:FBaseUnitId</param> /// <param name="baseDataFieldValue">基础资料字段主键值:10087</param> private void SetBasedataValue(BusinessInfo bizInfo, string baseDataFieldKey,DynamicObject dynObj, object baseDataFieldValue) { BaseDataField bdField = bizInfo.GetField(baseDataFieldKey) as BaseDataField; DynamicObject[] bdObjs = BusinessDataServiceHelper.LoadFromCache(this.Context, new object[] { baseDataFieldValue }, bdField.RefFormDynamicObjectType); if (bdField.Entity is Kingdee.BOS.Core.Metadata.EntityElement.SubHeadEntity) { var subData = dynObj[bdField.Entity.EntryName] as DynamicObjectCollection; if (subData.Count == 0) { subData.Add(new DynamicObject(bdField.Entity.DynamicObjectType)); } bdField.RefIDDynamicProperty.SetValue(subData[0], baseDataFieldValue); bdField.DynamicProperty.SetValue(subData[0], bdObjs[0]); } else { bdField.RefIDDynamicProperty.SetValue(dynObj, baseDataFieldValue); bdField.DynamicProperty.SetValue(dynObj, bdObjs[0]); } }
大佬,这个用python怎么实现
创建物料的DynamicObject数据包并保存
下面的代码演示了如何在表单插件创建一个新物料,并保存。/// <summary>/// 创建DynamicOjbect数据包并保存/// </summary>private void Sav...
点击下载文档
上一篇:账表点击超链接打开单据不对的问题分析下一篇:跨单据体携带字段案例
本文2024-09-16 17:19:39发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14985.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章