Li Jun
2022-05-10 51fb56f3f5b0dc96d7f93a71f9b61263e303243f
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>submit_approval_process</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;{!LostReport__c.Status__c}&apos; == &apos;填写完毕&apos; ||
        &apos;{!LostReport__c.Status__c}&apos; == &apos;申请中&apos; ||
        &apos;{!LostReport__c.Status__c}&apos; == &apos;已批准&apos;) {
        alert(&apos;请确认遗失报告状态,已经提交过的申请,不能重复提交&apos;);
        return;
    }
 
    if (!confirm(&quot;一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?&quot;)) {
        return;
    }
 
    var query = &quot;SELECT Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c FROM LostReport_Detail__c WHERE Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c != null AND LostReport__c = &apos;{!LostReport__c.Id}&apos;&quot;; 
    sforce.connection.sessionId = &quot;{!$Api.Session_ID}&quot;;
    var records = sforce.connection.query(query).getArray(&apos;records&apos;);
    console.log(query);
    if (records.length &gt; 0) {
        var qianpinDate = new Date(records[0].Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c);
        for (var i = 1; i &lt; records.length; i++) {
            var d = new Date(records[i].Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c);
            if(d &lt; qianpinDate){
                qianpinDate = d;
            }
        }
        qianpinDate.setDate(qianpinDate.getDate() + 90);
        var d = &apos;&apos; + qianpinDate.getFullYear()+&apos;/&apos; + (qianpinDate.getMonth()+1) + &apos;/&apos; + qianpinDate.getDate();
        alert(&apos;请您的上级领导于&apos; + d + &apos;前完成遗失报告审批,否则备品自动断念,遗失报告自动取消。&apos;);
    }
 
    var rac = new sforce.SObject(&quot;LostReport__c&quot;);
    rac.Id = &quot;{!LostReport__c.Id}&quot;;
    rac.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;
    }
    window.location.reload();
};
foo();</url>
</WebLink>