| <?xml version="1.0" encoding="UTF-8"?> | 
| <WebLink xmlns="http://soap.sforce.com/2006/04/metadata"> | 
|     <fullName>Select_Substitute</fullName> | 
|     <availability>online</availability> | 
|     <displayType>massActionButton</displayType> | 
|     <linkType>javascript</linkType> | 
|     <masterLabel>分配代替品</masterLabel> | 
|     <openType>onClickJavaScript</openType> | 
|     <protected>false</protected> | 
|     <requireRowSelection>true</requireRowSelection> | 
|     <url>{!RequireScript("/soap/ajax/51.0/connection.js")}  | 
| {!RequireScript("/soap/ajax/51.0/apex.js")} | 
| {!RequireScript("/resource/CommonUtilJs")}  | 
| //2021-10-21 gwy 版本更改为51.0 | 
| var records = {!GETRECORDIDS($ObjectType.Rental_Apply_Equipment_Set__c)}; | 
|   | 
| if (records.length < 1) { | 
|     alert("请选择一条借出备品一览记录"); | 
| } else if (records.length > 1) { | 
|     alert("只能选择一条记录"); | 
| } else { | 
|   | 
|     // 可分配代替品前提1 -- 备品借出申请的状态:“已批准”到“已出库指示” | 
|     if('{!Rental_Apply__c.Status__c}' != '已批准' && '{!Rental_Apply__c.Status__c}' != '已出库指示') { | 
|         alert('申请书状态不符合分配代替品条件,请确认申请的状态'); | 
|     } else { | 
|         // 可分配代替品前提2 -- 所选借出备品配套一览的状态:‘已批准’到‘出库前已检测’ | 
|         var soql = "select Cancel_Select__c,Irreplaceable_flag__c,RAES_Status__c,Shippment_loaner_time2__c from Rental_Apply_Equipment_Set__c where Id='"  | 
|  + records[0] + "'"; | 
|         var soqlRecords = sforce.connection.query(soql).getArray("records"); | 
|         var status = soqlRecords[0].RAES_Status__c;   | 
|         var irreplaceable = soqlRecords[0].Irreplaceable_flag__c; | 
|         var shipTime = soqlRecords[0].Shippment_loaner_time2__c; | 
|   | 
|         if(status == "草案中" || status == "申请中" || shipTime != null) { | 
|             alert("一览的状态不符合分配替代品条件"); | 
|         } else if(irreplaceable=="true") { | 
|             alert("申请人勾选了代替品不可"); | 
|         } else { | 
|             window.open("/apex/RentalFixtureSetSelect?pt_recid={!Rental_Apply__c.Id}&raesid="+records[0]); | 
|         }     | 
|     } | 
|      | 
| }</url> | 
| </WebLink> |