From bfca7a84bec815da594f1d12558535ed06d2490b Mon Sep 17 00:00:00 2001
From: 沙世明 <shashiming@prec-tech.com>
Date: 星期二, 13 九月 2022 09:57:32 +0800
Subject: [PATCH] 本地提交备份
---
force-app/main/default/classes/RentalApplyController.cls | 54 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/force-app/main/default/classes/RentalApplyController.cls b/force-app/main/default/classes/RentalApplyController.cls
index 2d7b16b..379f41e 100644
--- a/force-app/main/default/classes/RentalApplyController.cls
+++ b/force-app/main/default/classes/RentalApplyController.cls
@@ -92,15 +92,7 @@
obj.put('OwnerId',UserInfo.getUserId());
}
- if(mso.containsKey('00N10000003Mp2H')){
- system.debug('00N10000003Mp2H='+mso.get('00N10000003Mp2H'));
- controller.getRecord().put('Status__c',mso.get('00N10000003Mp2H'));
- }
-
- if(mso.containsKey('00N10000007oQKh')){
- system.debug('00N10000007oQKh='+mso.get('00N10000007oQKh'));
- controller.getRecord().put('Split_Apply_Reason__c',mso.get('00N10000007oQKh'));
- }
+ AssignValueFromUrl(mso,controller.getRecord());
system.debug('Rental Apply Record Type:'+rtTypeId);
LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Rental_Apply__c','classic');
layoutSections = LayoutWrapperValue.layoutSections;
@@ -118,6 +110,50 @@
AWSToSobjectEncryptedMap.put(PIDetail.AWS_Field_API__c, PIDetail.SF_Field_API_Name__c);
}
}
+
+ public static void AssignValueFromUrl(Map<string,string> mso, sobject sobj){
+ Map<string,object> temp = new Map<string,object>();
+ Map<string,FieldDefinition> fdm = new Map<string,FieldDefinition>();
+ List<FieldDefinition> fds = [SELECT Id, DurableId, QualifiedApiName, EntityDefinitionId, NamespacePrefix, DeveloperName, MasterLabel, Label FROM FieldDefinition where EntityDefinition.QualifiedApiName = 'Rental_Apply__c'];
+ for(FieldDefinition fd : fds){
+ //system.debug(fd.DurableId);
+ fdm.put(fd.DurableId.split('\\.')[1],fd);
+ }
+
+ for(string key : mso.keySet()){
+ string new_key = key;
+ system.debug('new_key='+new_key);
+ if(new_key.contains('_lkid')){
+ new_key = new_key.replace('_lkid', '');
+ new_key = new_key.substring(2);
+ }else{
+ if(temp.containsKey(new_key)){
+ continue;
+ }
+ }
+
+ system.debug('now new_key='+new_key);
+ if(fdm.containsKey(new_key)){
+ string val = EncodingUtil.urlDecode(mso.get(key),'UTF-8');
+ if(string.isBlank(val)){
+ val = null;
+ }
+ temp.put(fdm.get(new_key).QualifiedApiName,val);
+ }else{
+ system.debug(key+' is not in fdm');
+ }
+ }
+
+ for(string key : temp.keySet()){
+ system.debug('assign '+key+'='+temp.get(key));
+ try{
+ sobj.put(key, temp.get(key));
+ }catch(Exception e){
+ system.debug(e.getMessage());
+ system.debug(e.getStackTraceString());
+ }
+ }
+ }
global class Response{
public String recordId{set;get;}
--
Gitblit v1.9.1