From f5a94e721ae5a26f817f0df75065b64f1f192eb3 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期一, 28 三月 2022 21:43:51 +0800
Subject: [PATCH] PIPLFunctionDeploy0328
---
force-app/main/default/classes/OnCallController.cls | 42 ++++++++++++++++++++++++++++++------------
1 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/force-app/main/default/classes/OnCallController.cls b/force-app/main/default/classes/OnCallController.cls
index f6beda8..23a15ff 100644
--- a/force-app/main/default/classes/OnCallController.cls
+++ b/force-app/main/default/classes/OnCallController.cls
@@ -1,4 +1,12 @@
+/**
+ * @description :
+ * @author : ChangeMeIn@UserSettingsUnder.SFDoc
+ * @group :
+ * @last modified on : 03-28-2022
+ * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
+**/
global without sharing class OnCallController {
+ public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute
public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;}
public String awsToken{set;get;}
public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
@@ -27,7 +35,9 @@
//鑾峰彇鎵�鏈夊瓧娈�
List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('On_Call__c').getDescribe().fields.getMap().keyset());
// Add fields to controller. This is to avoid the SOQL error in visualforce page
- controller.addFields(fieldList);
+ if(!Test.isRunningTest()){
+ controller.addFields(fieldList);
+ }
SObject obj = controller.getRecord();
if(obj.Id != null){
//鏇存柊
@@ -37,9 +47,11 @@
}else{
//鏂板缓
rtTypeId = null;
+ obj.put('OwnerId',UserInfo.getUserId());
}
LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'On_Call__c','classic');
layoutSections = LayoutWrapperValue.layoutSections;
+ layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute
List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList;
Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap;
requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList);
@@ -67,21 +79,27 @@
//鑷畾涔夋牸寮忚浆鎹�
for (String fieldAPI: fieldValueMap.keySet()) {
system.debug('field API'+fieldAPI);
- Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType();
- String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI));
- if(String.isBlank(fieldValue)){
+ if(!fieldAPIToTypeMap.containskey(fieldAPI)){
continue;
}
+ Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType();
+ String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI));
if(String.valueOf(fielddataType)=='DATE'){
- onCallInfo.put(fieldAPI, Date.valueOf(String.valueOf(fieldValueMap.get(fieldAPI)).replace('/', '-')));
+ onCallInfo.put(fieldAPI,(String.isBlank(fieldValue)||String.isEmpty(fieldValue))? null:Date.valueOf(fieldValue.replace('/', '-')));
}else if(String.valueOf(fielddataType)=='DATETIME'){
- String dt = String.valueOf(fieldValueMap.get(fieldAPI));
- if(String.isNotBlank(dt)&&dt.contains('T')){
- dt = dt.replace('T',' ');
- onCallInfo.put(fieldAPI, Datetime.valueOfGmt(dt));
- }
- }else if(String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
- onCallInfo.put(fieldAPI, Decimal.valueOf(String.valueOf(fieldValueMap.get(fieldAPI))));
+ if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){
+ fieldValue = fieldValue.replace('T',' ');
+ onCallInfo.put(fieldAPI, Datetime.valueOfGmt(fieldValue));
+ }else if(String.isNotBlank(fieldValue)) {
+ fieldValue = fieldValue.replace('/', '-') + ':00';
+ System.debug('fieldValue = ' + fieldValue);
+ onCallInfo.put(fieldAPI, Datetime.valueOf(fieldValue));
+ }else{
+ onCallInfo.put(fieldAPI, null);
+ }
+
+ }else if(String.valueOf(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='CURRENCY'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
+ onCallInfo.put(fieldAPI, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?null:Decimal.valueOf(fieldValue.replace(',', '')));
} else if(String.valueof(fielddataType)=='BOOLEAN'){
onCallInfo.put(fieldAPI, fieldValueMap.get(fieldAPI));
}else {
--
Gitblit v1.9.1