废话不多说,直接上代码
##****************************保存服务插件*******************
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.Contracts')
clr.AddReference('Kingdee.BOS.ServiceHelper')
clr.AddReference('Kingdee.BOS.App.Core')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Msg import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.DataEntity import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.App.Core import *
from Kingdee.BOS.App.Core.Messages import *
from System import *
from System.Data import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
def EndOperationTransaction(e):
for billObj in e.DataEntitys:
billNo = str(billObj["BillNo"]);
userXunTongService=UserXunTongService();
toUsers=List[str]();
xunTongOpenId=userXunTongService.GetXunTongUser(this.Context,"5e8bd88fe4b0076XXXX");
toUsers.Add(str(xunTongOpenId));
xunTongService=ServiceFactory.GetXunTongService(this.Context);
xunTongService=XunTongService();
msg=XTPlainTextMessage();
msg.Text = ("测试消息:审核了单据[{0}]").format(billNo);
msg.PubAcctCode = "XT-31d79e2d-0541-4d64-8bf7-XXXXX";
msg.PubAcctKey = "1c341b7de803c2664fXXXXX";
msg.Users=toUsers;
xtsendResult=xunTongService.AnsySendPlainTextMessage(this.Context, msg);
ss=("结果:{0}").format(xtsendResult.Msg);
#raise Exception(ss);
推荐阅读