<?xml version="1.0" encoding="UTF-8"?> 
 | 
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata"> 
 | 
    <fullName>NewAgencyHospital</fullName> 
 | 
    <availability>online</availability> 
 | 
    <displayType>massActionButton</displayType> 
 | 
    <linkType>javascript</linkType> 
 | 
    <masterLabel>新建经销商医院</masterLabel> 
 | 
    <openType>onClickJavaScript</openType> 
 | 
    <protected>false</protected> 
 | 
    <requireRowSelection>false</requireRowSelection> 
 | 
    <url>{!REQUIRESCRIPT("/soap/ajax/51.0/connection.js")}; 
 | 
{!REQUIRESCRIPT("/soap/ajax/51.0/apex.js")}; 
 | 
//2021-10-22 gwy 版本更改为51.0 
 | 
var doubleFlg = false; 
 | 
if(!doubleFlg) { 
 | 
    doubleFlg = true; 
 | 
    var query = "Select Id From RecordType Where DeveloperName = 'AHospital' And SobjectType = 'Agency_Hospital_Link__c'"; 
 | 
    var records = sforce.connection.query(query).getArray('records'); 
 | 
    var rtId = records[0].Id; 
 | 
    query = "Select EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Agency_Hospital_Link__c' And QualifiedApiName = 'Agency__c'"; 
 | 
    records = sforce.connection.query(query).getArray('records'); 
 | 
    var prefix = records[0].EntityDefinition.KeyPrefix.toString(); 
 | 
    var fId_Agency__c = records[0].DurableId.toString().substr(16, 15); 
 | 
    var newUrl = "/" + prefix + "/e?retURL=%2F{!Account.Id}" +  
 | 
        "&Name=*" + 
 | 
        "&CF" + fId_Agency__c + "={!URLENCODE(Account.Name)}" + 
 | 
        "&CF" + fId_Agency__c + "_lkid={!Account.Id}"; 
 | 
    if (window.top == window.self) { 
 | 
        location.href = newUrl; 
 | 
    } else { 
 | 
        top.location.href = newUrl; 
 | 
    } 
 | 
}</url> 
 | 
</WebLink> 
 |