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/NewConsumApplyController.cls | 49 ++++++++++++++++++++++++++++++++----------------- 1 files changed, 32 insertions(+), 17 deletions(-) diff --git a/force-app/main/default/classes/NewConsumApplyController.cls b/force-app/main/default/classes/NewConsumApplyController.cls index b1bc107..a50680e 100644 --- a/force-app/main/default/classes/NewConsumApplyController.cls +++ b/force-app/main/default/classes/NewConsumApplyController.cls @@ -2,7 +2,7 @@ * @description : * @author : ChangeMeIn@UserSettingsUnder.SFDoc * @group : - * @last modified on : 03-23-2022 + * @last modified on : 03-28-2022 * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc **/ global without sharing class NewConsumApplyController { @@ -30,7 +30,9 @@ PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg; //鑾峰彇鎵�鏈夊瓧娈� List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Consum_Apply__c').getDescribe().fields.getMap().keyset()); - controller.addFields(fieldList); + if (!Test.isRunningTest()) { + controller.addFields(fieldList); + } SObject obj = controller.getRecord(); if(obj.Id != null){ //鏇存柊 @@ -49,6 +51,15 @@ //鏂板缓 rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); obj.put('OwnerId',UserInfo.getUserId()); + Map<string,string> mso = ApexPages.currentPage().getParameters(); + system.debug('mso='+mso); + if(mso.containsKey('00N10000008rdgs')){ + controller.getRecord().put('demo_purpose2__c',mso.get('00N10000008rdgs')); + } + if(mso.containsKey('Name')){ + controller.getRecord().put('Name',mso.get('Name')); + } + } LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Consum_Apply__c','classic'); layoutSections = LayoutWrapperValue.layoutSections; @@ -79,29 +90,33 @@ Consum_Apply__c consumApplyInfo = new Consum_Apply__c(); //鑷畾涔夋牸寮忚浆鎹� for (String fieldAPI: fieldValueMap.keySet()) { - Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType(); - String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI)); - if(String.isBlank(fieldValue)){ + system.debug('field API'+fieldAPI); + 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'){ - System.debug('DATE fieldAPI = '+fieldAPI+' filedData = '+String.valueOf(fieldValueMap.get(fieldAPI))); - consumApplyInfo.put(fieldAPI, Date.valueOf(String.valueOf(fieldValueMap.get(fieldAPI)).replace('/', '-'))); + consumApplyInfo.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',' '); - consumApplyInfo.put(fieldAPI, Datetime.valueOfGmt(dt)); - }else if(String.isNotBlank(dt)) { - consumApplyInfo.put(fieldAPI, Datetime.valueOf(dt)); - } - }else if(String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){ - consumApplyInfo.put(fieldAPI, Decimal.valueOf(String.valueOf(fieldValueMap.get(fieldAPI)))); + if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){ + fieldValue = fieldValue.replace('T',' '); + consumApplyInfo.put(fieldAPI, Datetime.valueOfGmt(fieldValue)); + }else if(String.isNotBlank(fieldValue)) { + fieldValue = fieldValue.replace('/', '-') + ':00'; + System.debug('fieldValue = ' + fieldValue); + consumApplyInfo.put(fieldAPI, Datetime.valueOf(fieldValue)); + }else{ + consumApplyInfo.put(fieldAPI, null); + } + + }else if(String.valueOf(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='CURRENCY'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){ + consumApplyInfo.put(fieldAPI, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?null:Decimal.valueOf(fieldValue.replace(',', ''))); } else if(String.valueof(fielddataType)=='BOOLEAN'){ consumApplyInfo.put(fieldAPI, fieldValueMap.get(fieldAPI)); }else { consumApplyInfo.put(fieldAPI, String.valueOf(fieldValueMap.get(fieldAPI))); - } + } } //2. Save Record Process -- Gitblit v1.9.1