单据转换插件里,通过AfterConvert事件来修改目标单数据包里的基础数据字段
记录一个下推时,能成功修改目标单里的基础数据字段的方法
using Kingdee.BOS.App.Core.Utils; using Kingdee.BOS.App.Data; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args; using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Core.Metadata.Util; using Kingdee.BOS.Core.Util; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace WPBR.FormicPhase2.SCM.ServicePlugIn.ConvertServicePlugIn { [Description("PO下推AP转换插件")] [HotUpdate] public class PoToApConvertServicePlugIn : AbstractConvertPlugIn { public override void AfterConvert(AfterConvertEventArgs e) { base.AfterConvert(e); if (e.Result == null) { return; } DynamicObject dynamicObject = e.Result.FindByEntityKey("FBillHead")[0].DataEntity; var profitCenter = dynamicObject["FProfitCenter_id"]; var department = dynamicObject["FDepartment_id"]; if (department == null || profitCenter == null) { return; } var organize = dynamicObject["SETTLEORGID_Id"]; var result = DBUtils.ExecuteDynamicObject(e.Context, $"SELECT * FROM MappingConfig_Entity where FOrganization = {organize} and FDepartment = {department} and FProfitCenter ={profitCenter}"); var mappingData = result.IsEmpty() == false ? result.First() : null; if (mappingData != null) { var accountPrimaryKey = mappingData["FAccount"]; var dataField = e.TargetBusinessInfo.GetField("FAccount") as BaseDataField; DynamicObject[] results = BusinessDataServiceHelper.Load(this.Context, new[] { accountPrimaryKey }, dataField.RefFormDynamicObjectType); //set value dynamicObject["FAccount"] = results.FirstOrDefault(); } } } }
关键代码就是最后几行,必须把基础资料的DynamicObject获取到,然后直接赋值给目标单的DynamicObject对应的字段。
单据转换插件里,通过AfterConvert事件来修改目标单数据包里的基础数据字段
记录一个下推时,能成功修改目标单里的基础数据字段的方法using Kingdee.BOS.App.Core.Utils;using Kingdee.BOS.App.Data;using Kingdee.BO...
点击下载文档
本文2024-09-16 17:41:55发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-17385.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章