|
|
A:如何发送微信通知?
Q:可以在表单,配置操作为“无”,在执行脚本上放如下脚本:
- (function(){
- var userids=getCurrentDocument().getItemValueAsString("接收人");//表单,获取接收人的值
- var touser="";
- if(userids!=""&&userids!=null){
- userids = userids.split(';');
- for (var i=0; i < userids.length; i++ ) {
- var touserid=userids[i];
- touser+=getUserById(touserid).getLoginno()+"|";
- }
- touser=touser.substring(0,touser.length-1);
- }
- var formid=getCurrentDocument().getFormid();
- var applicationId=getApplication();
- var domainId=getDomainid();
- var docid=getCurrentDocument().getId();
- var request = $WEB.getParamsTable().getHttpRequest();//获取当前request
- //如果服务器本身就可以访问,就可以通过函数获取
- var url0="http://"+request.getServerName()+":"+request.getServerPort()+getContextPath();
- var url1="http://office.teemlink.com:65533/Z0271IDV"+"/portal/dynaform/document/view.action?_docid="+docid+"&_formid="+formid+"&application="+applicationId;
- //打开的url需要转码
- url1=encodeURIComponent(url1);
- var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe36ce2ae5ff0a86c&redirect_uri="+url1+"&response_type=code&scope=snsapi_base&state="+domainId+"#wechat_redirect";
- var title="发送的标题";
- var description="发送的内容";
- var picUrl=url1+"/resource/image/photo.png";
- var flag=sendWeixinRichTextMessage(touser,title,description,url,picUrl,domainId,applicationId);
- println("flag==========="+flag);
- return "";
- })()
复制代码
如果在1.4.3版本之后,发送通知的格式有变化调整为
- (function(){
- var docid = getId();
- var users = getItemValueAsString("送阅用户");
- var receiver = ""; //|分隔
- var isReply = false;
- var isMass = false;
- if(users != null && !"".equals(users)){
- var users1 = splitText(users,";");
- for(var ii=0;ii<users1.length;ii++){
- var userVo = getUserById(users1[ii]);
- if(userVo != null){
- if("".equals(receiver)){
- receiver += userVo.getLoginno();
- }else{
- receiver += "|" + userVo.getLoginno();
- }
- }
- }
- }
- var formid=getCurrentDocument().getFormid();
- var applicationId=getApplication();
- var domainId=getDomainid();
- var docid=getCurrentDocument().getId();
- var request = $WEB.getParamsTable().getHttpRequest();//获取当前request
- //如果服务器本身就可以访问,就可以通过函数获取
- var url0="http://"+request.getServerName()+":"+request.getServerPort()+getContextPath();
- var url1=url0+"/portal/dynaform/document/view.action?_docid="+docid+"&_formid="+formid+"&application="+applicationId;
- //打开的url需要转码
- url1=encodeURIComponent(url1);
-
- url1=url0+ "/portal/phone/main.jsp?application="+applicationId+"&jumpToUrl="+url1
- println("urlPC========"+url1);
- //需要再次转码
- url1=encodeURIComponent(url1);
- var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5e502f52d41dfb08&redirect_uri="+url1+"&response_type=code&scope=snsapi_base&state="+domainId+"#wechat_redirect";
- println("urlWETCHAT==============="+url);
- var title=getCurrentDocument().getItemValueAsString("标题");
- var description=getCurrentDocument().getItemValueAsString("类别");
- var picUrl="http://www.fxwq365.com/Z01R1"+"/uploads/tzbanner/fxtz.jpg";
- var flag=sendWeixinRichTextMessage(receiver,title,description,url,picUrl,domainId,applicationId);
- println("flag==========="+flag);
- return "";
- })()
复制代码 |
|