张宇恒
2022-03-18 d2ef556f29fee3925f06221bba078dcbb8f85c0b
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>VOCCheck</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>VOC判定</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;{!$User.Id}&quot; != &quot;00510000000gWAE&quot; &amp;&amp; &quot;{!$User.Id}&quot; != &quot;00510000004reg2&quot; &amp;&amp; &quot;{!$Profile.Id}&quot; != &quot;00e10000000Y3o5&quot;) {
        alert(&quot;你没有判定VOC的权限&quot;);
        return;
    }
    if (&quot;{!Report__c.Status__c}&quot; != &quot;跟进中&quot;) {
        alert(&quot;不是跟进中不能点击&quot;);
        return;
    }
    if (&quot;{!Report__c.IsVOC__c}&quot; == &quot;&quot;) {
        alert(&quot;必须选择是否VOC&quot;);
        return;
    }
    var rac = new sforce.SObject(&quot;Report__c&quot;);
    var result;
    rac.Id = &quot;{!Report__c.Id}&quot;;
    if (&quot;{!Report__c.IsVOC__c}&quot; == &quot;VOC&quot;) {
        // VOC対応者の経理部長総監を設定
        var resultSet = sforce.connection.query(&quot;SELECT Id, Job_Category__c, JingliApprovalManager__c, SalesManager__c, BuchangApprovalManager__c, BuchangApprovalManagerSales__c, ZongjianApprovalManager__c FROM User WHERE Id = &apos;{!Report__c.Responsible_PersonId__c}&apos;&quot;);
        var records = resultSet.getArray(&quot;records&quot;);
        if (records[0].Job_Category__c == &quot;销售服务&quot;) {
            rac.VOC_jingli__c = records[0].JingliApprovalManager__c == null ? &quot;&quot; : records[0].JingliApprovalManager__c;
            rac.VOC_buzhang__c = records[0].BuchangApprovalManager__c == null ? &quot;&quot; : records[0].BuchangApprovalManager__c;
        } else {
            rac.VOC_jingli__c = records[0].SalesManager__c == null ? &quot;&quot; : records[0].SalesManager__c;
            rac.VOC_buzhang__c = records[0].BuchangApprovalManagerSales__c == null ? &quot;&quot; : records[0].BuchangApprovalManagerSales__c;
        }
        rac.VOC_zongjian__c = records[0].ZongjianApprovalManager__c == null ? &quot;&quot; : records[0].ZongjianApprovalManager__c;
        rac.Status__c = &quot;判定完毕&quot;;
        rac.VOC_Finish__c = false;
        var serverTimestamp = sforce.connection.getServerTimestamp();
        rac.VOC_share_date__c = serverTimestamp.timestamp;
        
        // share
        var userAccess = new Array();
        userAccess.push(&apos;{!Report__c.Responsible_PersonId__c}_Edit&apos;);
        userAccess.push(rac.VOC_jingli__c + &apos;_Read&apos;);
        userAccess.push(rac.VOC_buzhang__c + &apos;_Read&apos;);
        userAccess.push(rac.VOC_zongjian__c + &apos;_Read&apos;);
        var rtn = sforce.apex.execute(&apos;ControllerUtil&apos;,&apos;setSObjectShare&apos;,{sobjectName:&apos;Report__Share&apos;,rowCause:&apos;VOCShare__c&apos;,parentId:&apos;{!Report__c.Id}&apos;,userAccess:userAccess,ownerId:&apos;{!Report__c.OwnerId}&apos;});
        if (rtn != &apos;OK&apos;) {
            alert(rtn);
            return;
        }
    
        result = sforce.connection.update([rac]);
    } else {
        rac.Status__c = &quot;完毕&quot;;
        rac.VOC_Finish__c = true;
        result = sforce.connection.update([rac]);
    }
    var messages = getConnectDMLErrorMessages(result);
    if (messages.length &gt; 0) {
        alert(messages.join(&quot;\n&quot;));
        return;
    }
    location.reload();
}
foo();</url>
</WebLink>