涂煌豪
2022-05-17 c406cfcd9ce37fd43711bb12b3dae2b3bd120c49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>cancelSubAuthorizedButton</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>取消</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <url>{!RequireScript(&quot;/soap/ajax/51.0/connection.js&quot;)} 
{!RequireScript(&quot;/soap/ajax/51.0/apex.js&quot;)} 
{!RequireScript(&quot;/resource/CommonUtilJs&quot;)} 
//2021-10-22 gwy 版本更改为51.0
var foo = function(){ 
if(&quot;{!SubAuthorized__c.Status__c}&quot; ==&apos;已取消&apos;){ 
alert(&apos;已经取消!&apos;); 
return; 
if(&quot;{!SubAuthorized__c.Status__c}&quot; !=&apos;草案中&apos; &amp;&amp; &quot;{!SubAuthorized__c.Status__c}&quot; !=&apos;申请中&apos; &amp;&amp; &quot;{!SubAuthorized__c.Status__c}&quot; !=&apos;已批准&apos;){ 
var msg = &quot;{!SubAuthorized__c.Status__c}&quot; +&apos;状态不能取消&apos;; 
alert(msg); 
return; 
var SubAuthorized = new sforce.SObject(&quot;SubAuthorized__c&quot;); 
SubAuthorized.Id = &quot;{!SubAuthorized__c.Id}&quot;; 
SubAuthorized.Status__c = &quot;已取消&quot;; 
var result = sforce.connection.update([SubAuthorized]); 
if(result[0].getBoolean(&quot;success&quot;)){ 
//success 
alert(&apos;已取消&apos;); 
location.href = &quot;/{!SubAuthorized__c.Id}&quot;; 
}else{ 
var ermsg = result[0].errors.message; 
alert(ermsg); 
foo();</url>
</WebLink>