From b3dc8e8ce0a120b4f484ef787abd21832c40ec63 Mon Sep 17 00:00:00 2001
From: 彭锟 <pengkun@prec-tech.com>
Date: 星期日, 24 四月 2022 10:07:34 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlyMEBG

---
 force-app/main/default/classes/NewAndEditContactController.cls |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/NewAndEditContactController.cls b/force-app/main/default/classes/NewAndEditContactController.cls
index 87e1afe..51152d2 100644
--- a/force-app/main/default/classes/NewAndEditContactController.cls
+++ b/force-app/main/default/classes/NewAndEditContactController.cls
@@ -6,23 +6,42 @@
         
         List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Contact').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);
+        }
         Init(controller.getRecord());
         String contactId = controller.getRecord().Id;
         if(contactId != null){
             Contact c = [select UnifiedI_Contact_ID__c from Contact where Id =:contactId ];
             system.debug('Contact c = '+c);
             unifiedIContactID = c.UnifiedI_Contact_ID__c;
+        }else{
+            Map<string,string> mso = ApexPages.currentPage().getParameters();
+            system.debug('mso='+mso);
+            system.debug('url='+ApexPages.currentPage().getUrl());
+            if(mso.containsKey('con4_lkid')){
+                controller.getRecord().put('AccountId',mso.get('con4_lkid'));
+            }
         }
+        system.debug('controller.getRecord()='+controller.getRecord());
 
     }
     
     PageReference RedirectStandardPage(){
         Map<string,string> mso = ApexPages.currentPage().getParameters();
         system.debug(mso);
+        PageReference pg = null;
         mso.remove('sfdc.override');
-        PageReference pg = new PageReference('/003/e');
-        mso.putAll(mso);
+        mso.remove('save_new');
+        system.debug('recordId='+recordId);
+        if(string.isBlank(recordId)){
+            pg = new PageReference('/003/e');
+        }else{
+            pg = new PageReference('/'+recordId+'/e');
+        }
+        pg.getParameters().putAll(mso);
+        //pg.getParameters().put('RecordType',mso.get('RecordType'));
+        //pg.getParameters().put('accid',mso.get('accid'));
         pg.getParameters().put('nooverride','1');
         pg.setRedirect(true);
         return pg;
@@ -31,7 +50,6 @@
     public PageReference PageLoad(){
         system.debug('rtTypeId='+rtTypeId);
         string s = null;
-        
         if(!string.isBlank(rtTypeId)){
             s = Schema.SObjectType.Contact.getRecordTypeInfosById().get(rtTypeId).getDeveloperName();
             if(s == 'Agency' || s == 'Internal_staff'){
@@ -50,6 +68,7 @@
             
             
         }
+        system.debug('null');
         return null;
     }
     

--
Gitblit v1.9.1