Li Jun
2022-04-08 ac719375874fd50fad5a11f8e04ac3329081bd0b
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>SubmitNewOpportunity_Agency_Apply</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 (&apos;{!Agency_Opportunity__c.NewOpportunity_Agency_Apply_Status_F__c}&apos; != &apos;不批准&apos; &amp;&amp; &apos;{!Agency_Opportunity__c.NewOpportunity_Agency_Apply_Status_F__c}&apos; != &apos;草案中&apos;) {
        alert(&apos;只有共享审批状态为草案中或者不批准时才可以提交共享审批&apos;);
        return;
    }
    
    if (!confirm(&quot;一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?&quot;)) {
        return;
    }
 
    var rac = new sforce.SObject(&quot;Agency_Opportunity__c&quot;);
    rac.Id = &quot;{!Agency_Opportunity__c.Id}&quot;;
    rac.NewOpportunity_Agency_Apply_Status__c = &quot;填写完毕&quot;;
    var result = sforce.connection.update([rac]);
    var messages = getConnectDMLErrorMessages(result);
    if (messages.length &gt; 0) {
        alert(messages.join(&quot;\n&quot;));
        return;
    }
 
    var request = new sforce.ProcessSubmitRequest();
    request.objectId = &quot;{!Agency_Opportunity__c.Id}&quot;;
    var processResults = sforce.connection.process([request]);
 
    if (processResults[0].errors != null) {
        var back = new sforce.SObject(&quot;Agency_Opportunity__c&quot;);
        back.Id = &quot;{!Agency_Opportunity__c.Id}&quot;;
        back.NewOpportunity_Agency_Apply_Status__c = &quot;不批准&quot;;
        var backResult = sforce.connection.update([back]);
        backMessages = getConnectDMLErrorMessages(backResult);
        if (backMessages.length &gt; 0) {
            alert(backMessages.join(&quot;\n&quot;));
            return;
        }
 
        var errmsg = processResults[0].errors.message.toString();
        alert(errmsg);
        return;
    }
    alert(&apos;已提交共享审批&apos;);
    window.location.reload();
};
foo();</url>
</WebLink>