金蝶云 python脚本 维度关联字段赋值之辅助属性

该脚本主要针对金蝶云平台,使用Python处理数据模型中的字段赋值,特别是针对维度字段的更新。当F_SHText、F_LHText、F_CDText、F_DTGGText等字段发生变化时,脚本会同步更新相关辅助属性$$FBAUXPROPID__FF100001到$$FBAUXPROPID__FF100004的值,并更新视图。此代码适用于自动化数据处理和业务流程自动化场景。
摘要由CSDN通过智能技术生成

金蝶云 python脚本 维度关联字段赋值之辅助属性

1.操作Model逐个维度进行赋值

引用库存在多余的引用不影响功能,自行选择是否删除。

import clr
clr.AddReference("System")
clr.AddReference("System.Data")
clr.AddReference("System.XML")
clr.AddReference("System.Web.Extensions")
#clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.ServiceHelper")
clr.AddReference("Newtonsoft.Json")
clr.AddReference("Kingdee.BOS.Contracts")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("System.Web")
clr.AddReference("Kingdee.BOS.WebApi.Client")
clr.AddReference("Kingdee.BOS.Model")
import sys
from System import *
from System.IO import *
from System.Net import *
from System.Web import *
from System.Text import *
from System.Threading import *
from System.Globalization import *
from System.Security.Cryptography import *
from System.Web.Script.Serialization import *
from System.Collections.Generic import List as syslist
from System.Collections.Generic import Dictionary
from Newtonsoft.Json.Linq import *
from Kingdee.BOS.Contracts import * 
from Kingdee.BOS.Core.List import * 
from Kingdee.BOS.Core.CommonFilter import * 
from Kingdee.BOS.Contracts.Report import *
from Kingdee.BOS.Core.Report import ISysReportView
from Kingdee.BOS.Core.Report import ReportTitles
from Kingdee.BOS.App import ServiceHelper as ServiceHelperAPP
from Kingdee.BOS.Orm.Metadata.DataEntity import *
#from Kingdee.BOS import *
from Kingdee.BOS.Model.DynamicForm import *
from Kingdee.BOS.WebApi.Client import *
from Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Core.Log import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Orm import OperateOption
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.DataEntity import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Core.Interaction import KDInteractionException
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Metadata import BusinessInfo
from Kingdee.BOS.Core.Metadata import SelectorItemInfo ##字段选择实体类
from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter ##查询参数实体类
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Orm.Metadata.DataEntity import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Core.Metadata.FieldElement import *

#修改默认编码为utf8
reload(sys)
sys.setdefaultencoding('utf-8') 

def _Zstr(a):
    return ("" if a==None else (a if isinstance(a,str) else str(a)));
def DataChanged(e):
	try:
		if e.Field.Key.upper()=="F_SHText".upper() or e.Field.Key.upper()=="F_LHText".upper() or e.Field.Key.upper()=="F_CDText".upper() or e.Field.Key.upper()=="F_DTGGText".upper():
			#单据体
			F_SHText=this.View.Model.GetValue("F_SHText",e.Row)
			F_LHText=this.View.Model.GetValue("F_LHText",e.Row)
			F_CDText=this.View.Model.GetValue("F_CDText",e.Row)
			F_DTGGText=this.View.Model.GetValue("F_DTGGText",e.Row)
			#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100001","" if F_SHText==None else F_SHText,e.Row);
			##this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100002","" if F_LHText==None else F_LHText,e.Row);
			#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100003","" if F_CDText==None else F_CDText,e.Row);
			#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100004","" if F_DTGGText==None else F_DTGGText,e.Row);
			this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100001", "" if F_SHText==None else F_SHText, e.Row);
			this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100002", "" if F_LHText==None else F_LHText, e.Row);
			this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100003", "" if F_CDText==None else F_CDText, e.Row);
			this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100004", "" if F_DTGGText==None else F_DTGGText, e.Row);
			this.View.UpdateView("$$FBAUXPROPID__FF100001", e.Row);
			this.View.UpdateView("$$FBAUXPROPID__FF100002", e.Row);
			this.View.UpdateView("$$FBAUXPROPID__FF100003", e.Row);
			this.View.UpdateView("$$FBAUXPROPID__FF100004", e.Row);
			this.View.UpdateView("FBAUXPROPID", e.Row);
	except Exception as e:
		raise Exception("错误:"+e.ToString());

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值