<?xml version="1.0" encoding="UTF-8"?> 
 | 
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata"> 
 | 
    <fullName>VOCSubmit</fullName> 
 | 
    <availability>online</availability> 
 | 
    <displayType>button</displayType> 
 | 
    <linkType>javascript</linkType> 
 | 
    <masterLabel>VOC提出</masterLabel> 
 | 
    <openType>onClickJavaScript</openType> 
 | 
    <protected>false</protected> 
 | 
    <url>{!RequireScript("/soap/ajax/51.0/connection.js")} 
 | 
{!RequireScript("/soap/ajax/51.0/apex.js")} 
 | 
{!RequireScript("/resource/CommonUtilJs")}  
 | 
//2021-10-22 gwy 版本更改为51.0 
 | 
var foo = function() { 
 | 
    if ("{!Report__c.Status__c}" != "草案中") { 
 | 
        alert("不是草案中不能点击"); 
 | 
        return; 
 | 
    } 
 | 
  
 | 
    var rac = new sforce.SObject("Report__c"); 
 | 
     
 | 
    // share 
 | 
    var resultSet = sforce.connection.query("SELECT Job_Category__c FROM User WHERE Id = '{!Report__c.CreatedById}'"); 
 | 
    var records = resultSet.getArray("records"); 
 | 
    var userAccess = new Array(); 
 | 
    if (records[0].Job_Category__c == "销售服务") { 
 | 
        userAccess.push('{!Report__c.JingliApprovalManagerId__c}_Read'); 
 | 
        userAccess.push('{!Report__c.BuchangApprovalManagerId__c}_Read'); 
 | 
        rac.VOC_CreatedBy_jingli__c = '{!Report__c.JingliApprovalManagerId__c}'; 
 | 
        rac.VOC_CreatedBy_buzhang__c = '{!Report__c.BuchangApprovalManagerId__c}'; 
 | 
    } else { 
 | 
        userAccess.push('{!Report__c.SalesManagerId__c}_Read'); 
 | 
        userAccess.push('{!Report__c.BuchangApprovalManagerSalesId__c}_Read'); 
 | 
        rac.VOC_CreatedBy_jingli__c = '{!Report__c.SalesManagerId__c}'; 
 | 
        rac.VOC_CreatedBy_buzhang__c = '{!Report__c.BuchangApprovalManagerSalesId__c}'; 
 | 
    } 
 | 
    userAccess.push('{!Report__c.ZongjianApprovalManagerId__c}_Read'); 
 | 
    var rtn = sforce.apex.execute('ControllerUtil','setSObjectShare',{sobjectName:'Report__Share',rowCause:'VOCShare__c',parentId:'{!Report__c.Id}',userAccess:userAccess,ownerId:'{!Report__c.OwnerId}'}); 
 | 
    if (rtn != 'OK') { 
 | 
        alert(rtn); 
 | 
        return; 
 | 
    } 
 | 
  
 | 
    rac.Id = "{!Report__c.Id}"; 
 | 
    rac.Status__c = "填写完毕"; 
 | 
    var serverTimestamp = sforce.connection.getServerTimestamp(); 
 | 
    rac.Submit_time__c = serverTimestamp.timestamp; 
 | 
    rac.Submit_report_day__c = serverTimestamp.timestamp; 
 | 
    var result = sforce.connection.update([rac]); 
 | 
  
 | 
    var messages = getConnectDMLErrorMessages(result); 
 | 
    if (messages.length > 0) { 
 | 
        alert(messages.join("\n")); 
 | 
        return; 
 | 
    } 
 | 
    location.reload(); 
 | 
} 
 | 
foo();</url> 
 | 
</WebLink> 
 |