From 3b43925ca3211c861a2818a089907d34b5480aa5 Mon Sep 17 00:00:00 2001
From: 张宇恒 <bxyun0@163.com>
Date: 星期五, 06 五月 2022 10:41:15 +0800
Subject: [PATCH] 批量数据拆分处理
---
force-app/main/default/classes/NewAndEditCaseController.cls | 33 ++++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/force-app/main/default/classes/NewAndEditCaseController.cls b/force-app/main/default/classes/NewAndEditCaseController.cls
index 4db40d0..dd6c070 100644
--- a/force-app/main/default/classes/NewAndEditCaseController.cls
+++ b/force-app/main/default/classes/NewAndEditCaseController.cls
@@ -13,6 +13,7 @@
public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public static String sobjectTypeValue = 'Case';
public Boolean isNewMode{set;get;}
+ public Boolean isCloneMode{protected set;get;}
public String rtTypeId {get; set;}
public String AWSDataId{set;get;}
public String contactId{set;get;}//For Lookup field
@@ -33,6 +34,7 @@
public string AWSToSobjectEncryptedMapJson{get{return JSON.serialize(AWSToSobjectEncryptedMap);}}
public NewAndEditCaseController(ApexPages.StandardController controller) {
isNewMode = true;
+ isCloneMode = false;
Input_Required_Field_Msg = Label.Input_Required_Field_Msg;
PIPL_Name_Label = Label.PIPL_Name_Label;
PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
@@ -40,6 +42,10 @@
//鑾峰彇鎵�鏈夊瓧娈�
List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Case').getDescribe().fields.getMap().keyset());
// Add fields to controller. This is to avoid the SOQL error in visualforce page
+ Map<string,string> mso = ApexPages.currentPage().getParameters();
+ if(mso != null && mso.containsKey('newclone')){
+ isCloneMode = true;
+ }
if (!Test.isRunningTest()) {
controller.addFields(fieldList);
}
@@ -60,7 +66,8 @@
contactsInfo = JSON.serialize(sfIdToAWSIdMap);
}else{
//鏂板缓
- rtTypeId = ApexPages.currentPage().getParameters().get('RecordType');
+ // rtTypeId = ApexPages.currentPage().getParameters().get('RecordType');
+ rtTypeId = mso.get('RecordType');
obj.put('OwnerId',UserInfo.getUserId());
}
LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Case','classic');
@@ -127,10 +134,13 @@
}
}
+ System.debug('caseInfo='+caseInfo);
System.debug('caseInfo.Account__c='+caseInfo.Account__c);
if (!String.isBlank(caseInfo.ContactId) && (String.isBlank(caseInfo.Account__c) || Id.valueOf(caseInfo.Account__c).to15() =='000000000000000')) {
- Contact c = [select id,AccountId from Contact where id = :caseInfo.ContactId];
- caseInfo.Account__c = c.AccountId;
+ if (Id.valueOf(caseInfo.ContactId).to15() !='000000000000000') {
+ Contact c = [select id,AccountId from Contact where id = :caseInfo.ContactId];
+ caseInfo.Account__c = c.AccountId;
+ }
}
//2. Save Record Process
@@ -138,18 +148,27 @@
Response resp = new Response();
Savepoint sp = Database.setSavepoint();
String rid = '';
+ String awsDataId = '';
+ Boolean isClone = false;
try{
System.debug('abcde');
- if(isNew){
+ awsDataId = (String)caseInfo.get('AWS_Data_Id__c');
+ System.debug('awsDataId = ' + awsDataId);
+ Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId];
+
+ if(!isNew){
+ isClone = cases.size() == 0;
+ }
+ if(isNew || isClone){
System.debug('caseInfozhj = ' + caseInfo);
if(!Test.isRunningTest()){
insert caseInfo;
}
}else{
System.debug('into update');
- String awsDataId = (String)caseInfo.get('AWS_Data_Id__c');
- System.debug('awsDataId = ' + awsDataId);
- Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId];
+ // String awsDataId = (String)caseInfo.get('AWS_Data_Id__c');
+ // System.debug('awsDataId = ' + awsDataId);
+ // Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId];
System.debug('cases ========================= ' + cases);
System.debug('Cases[0].id = ' + cases[0].id);
caseInfo.put('Id',cases[0].id);//For testing;
--
Gitblit v1.9.1