高章伟
2022-03-10 8db20630a2675ca14e03ccdee91c614397b5c964
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>ClearStatus</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() {
 
var result = sforce.connection.query(&quot;SELECT Id, Name, Inventory_Status__c FROM Inventory_Header_Copy__c WHERE Id=&apos;{!Inventory_Header_Copy__c.Id}&apos; OR Fixture_Header__c = &apos;{!Inventory_Header_Copy__c.Id}&apos;&quot;);
 
var records = result.getArray(&quot;records&quot;);
for(var i=0;i&lt;records.length;i++){
    if (records[i].Inventory_Status__c != &apos;处理中&apos;&amp;&amp; records[i].Inventory_Status__c!=null) {
        alert(records[i].Name+&apos;的盘点状态为【&apos;+records[i].Inventory_Status__c+&apos;】,不能清除此盘点状态。&apos;);
        return;
    }
}
if (!confirm(&quot;请确认是否要清除盘点状态?&quot;)) { 
    return;
}
 
 
for(var i=0;i&lt;records.length;i++){
    records[i].Inventory_Status__c = null; 
}
 
var result = sforce.connection.update(records); 
var messages = getConnectDMLErrorMessages(result); 
if (messages.length &gt; 0) {
  alert(messages.join(&quot;\n&quot;));
  return;
}
window.location.reload();
 
}
foo();</url>
</WebLink>