From ea5686cada5a3e63edaa0d3e8c2db8def4f9ff31 Mon Sep 17 00:00:00 2001 From: Li Jun <buli@deloitte.com.cn> Date: 星期一, 11 四月 2022 11:52:41 +0800 Subject: [PATCH] PIPLCloneButton --- force-app/main/default/classes/RentalApplyController.cls | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff --git a/force-app/main/default/classes/RentalApplyController.cls b/force-app/main/default/classes/RentalApplyController.cls index 24037c2..fac0fb0 100644 --- a/force-app/main/default/classes/RentalApplyController.cls +++ b/force-app/main/default/classes/RentalApplyController.cls @@ -1,10 +1,3 @@ -/** - * @description : - * @author : ChangeMeIn@UserSettingsUnder.SFDoc - * @group : - * @last modified on : 03-28-2022 - * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc -**/ global without sharing class RentalApplyController { public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;} @@ -12,6 +5,7 @@ public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); public static String sobjectTypeValue = 'Rental_Apply__c'; public Boolean isNewMode{set;get;} + public Boolean isCloneMode{protected set;get;} public String rtTypeId {get; set;} public String AWSDataId{set;get;} public List<String> encryptedAPIList{set;get;} @@ -30,10 +24,15 @@ public RentalApplyController(ApexPages.StandardController controller) { ApiPrefix = 'PIBackApi'; isNewMode = true; + isCloneMode = false; Input_Required_Field_Msg = Label.Input_Required_Field_Msg; PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg; //鑾峰彇鎵�鏈夊瓧娈� List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Rental_Apply__c').getDescribe().fields.getMap().keyset()); + Map<string,string> mso = ApexPages.currentPage().getParameters(); + if(mso != null && mso.containsKey('newclone')){ + isCloneMode = true; + } if(!Test.isRunningTest()){ controller.addFields(fieldList); } @@ -51,7 +50,7 @@ contactsInfo = JSON.serialize(sfIdToAWSIdMap); }else{ //鏂板缓 - Map<string,string> mso = ApexPages.currentPage().getParameters(); + // Map<string,string> mso = ApexPages.currentPage().getParameters(); system.debug('mso='+mso); if(mso.containsKey('Name')){ controller.getRecord().put('Name',mso.get('Name')); @@ -151,17 +150,26 @@ Response resp = new Response(); Savepoint sp = Database.setSavepoint(); String rid = ''; + Boolean isClone = false; + String awsDataId = ''; try{ System.debug('abcde'); - if(isNew){ + awsDataId = (String)rentalApplyInfo.get('AWS_Data_Id__c'); + System.debug('awsDataId = ' + awsDataId); + Rental_Apply__c[] RentalApplys = [select id from Rental_Apply__c where AWS_Data_Id__c =:awsDataId]; + if(!isNew){ + isClone = RentalApplys.size() == 0; + } + + if(isNew || isClone){ System.debug('rentalApplyInfozhj = ' + rentalApplyInfo); insert rentalApplyInfo; System.debug('rentalApplyInfo.Id' + rentalApplyInfo.Id); }else{ System.debug('into update'); - String awsDataId = (String)rentalApplyInfo.get('AWS_Data_Id__c'); - System.debug('awsDataId = ' + awsDataId); - Rental_Apply__c[] RentalApplys = [select id from Rental_Apply__c where AWS_Data_Id__c =:awsDataId]; + // String awsDataId = (String)rentalApplyInfo.get('AWS_Data_Id__c'); + // System.debug('awsDataId = ' + awsDataId); + // Rental_Apply__c[] RentalApplys = [select id from Rental_Apply__c where AWS_Data_Id__c =:awsDataId]; System.debug('RentalApplys[0].id = ' + RentalApplys[0].id); rentalApplyInfo.put('Id',RentalApplys[0].id);//For testing; update rentalApplyInfo; -- Gitblit v1.9.1