binxie
2024-01-20 1d91be0be5220ce19ee64de5a5c9a8237b1c15b1
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>EditLost</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;)};
 
function foo(){
var sql = &quot;select id,Report_Status__c,RecordTypeId from Lost_cancel_report__c where RecordTypeId != &apos;01210000000R4hHAAS&apos; and Opportunity__c =&apos;&quot; + &apos;{!Opportunity.Id}&apos;+ &quot;&apos;&quot;;
var sqlResult = sforce.connection.query(sql);
var lostlist = sqlResult.getArray(&quot;records&quot;);
var profileId = &apos;{!$User.ProfileId}&apos;;
var AprofileId = {!CONTAINS($Label.PCLReportProfileId, $User.ProfileId )};
 
if (sqlResult.size &lt; 0){
alert(&apos;请先创建失单报告&apos;);
return;
}else if(sqlResult.size &gt; 1){
//alert(&apos;1&apos;);
for(var lost of lostlist ){
//alert(&apos;3&apos;);
//alert(lost.RecordTypeId);
if(lost.RecordTypeId == &apos;01210000000R4hMAAS&apos;){
//alert(&apos;4&apos;);
if(lost.Report_Status__c == &apos;草案&apos; || profileId == &apos;00e10000000Y3o5&apos; || (lost.Report_Status__c == &apos;批准&apos; &amp;&amp; AprofileId)){
//alert(&apos;5&apos;);
window.open(&quot;/apex/PCLLostReportPage?pageStatus=Edit&amp;Id=&quot;+lost.Id);
}else{
window.open(&quot;/apex/PCLLostReportPage?pageStatus=View&amp;Id=&quot;+lost.Id);
}
}
}
}
else{
//alert(&apos;2&apos;);
//var status = lostlist[0].Report_Status__c;
if(lostlist[0].Report_Status__c == &apos;草案&apos; || profileId == &apos;00e10000000Y3o5&apos; || (lostlist[0].Report_Status__c == &apos;批准&apos; &amp;&amp; AprofileId)){
window.open(&quot;/apex/PCLLostReportPage?pageStatus=Edit&amp;Id=&quot;+lostlist[0].Id);
}else{
window.open(&quot;/apex/PCLLostReportPage?pageStatus=View&amp;Id=&quot;+lostlist[0].Id);
}
}
}
foo();</url>
</WebLink>