Submit_For_Approval online button javascript 提交待审批 onClickJavaScript false {!RequireScript("/soap/ajax/51.0/connection.js")} {!RequireScript("/soap/ajax/51.0/apex.js")} {!RequireScript("/resource/CommonUtilJs")} //2021-10-21 gwy 版本更改为51.0 var foo = function() { var attachments = sforce.connection.query("select id,name from solutionClosingAttachment__c where Solution_Programme__c = '{!Solution_Programme__c.Id}'"); var records= attachments.getArray("records"); if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { return; } if('{!Solution_Programme__c.Scheme_Type__c}'=='结案' && '{!Solution_Programme__c.Confirmation_Result__c}' == ''){ alert('结案方案提交前,方案采纳结果必填'); return; } if((records.length > 0 && '{!Solution_Programme__c.Scheme_Type__c}'=='结案')||('{!Solution_Programme__c.Scheme_Type__c}'=='初次')){ sforce.connection.sessionId = "{!$Api.Session_ID}"; var isopd = new sforce.SObject("Solution_Programme__c"); isopd.Id = "{!Solution_Programme__c.Id}"; isopd.Submint_TF__c = true; try { var result = sforce.connection.update([isopd]); var messages = getConnectDMLErrorMessages(result); if (messages.length > 0) { alert(messages.join("\n")); return; } } catch (err) { if(err.faultstring !=undefined && err.faultstring.indexOf('INVALID_SESSION_ID') != -1) { alert('当前网页已登出,请您重新登录后刷新该网页!'); } else { alert(err.faultstring); } return; } }else{ alert('结案的方案提交前,必须上传结案附件'); return; } window.location.reload(); }; foo();