From 08a21f49f2eaf9cfc19ceb67b196cc36ba689305 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 13 五月 2022 20:52:25 +0800 Subject: [PATCH] FIxSWOPageIssue --- force-app/main/default/classes/NewAndEditContactController.cls | 72 ++++++++++++++++++++++++++++++++++-- 1 files changed, 68 insertions(+), 4 deletions(-) diff --git a/force-app/main/default/classes/NewAndEditContactController.cls b/force-app/main/default/classes/NewAndEditContactController.cls index b5a7688..70b5fce 100644 --- a/force-app/main/default/classes/NewAndEditContactController.cls +++ b/force-app/main/default/classes/NewAndEditContactController.cls @@ -18,7 +18,13 @@ // Add fields to controller. This is to avoid the SOQL error in visualforce page //Get Account Id from url param - this.accountId = ApexPages.currentPage().getParameters().get('retURL'); + // this.accountId = ApexPages.currentPage().getParameters().get('retURL'); + system.debug('mso='+ApexPages.currentPage().getParameters()); + this.accountId = ApexPages.currentPage().getParameters().get('accid'); + if(string.isBlank(this.accountId)){ + system.debug('retake accid'); + this.accountId = ApexPages.currentPage().getParameters().get('con4_lkid'); + } System.debug('accountId = ' + accountId); // System.debug('accountType = ' + ); @@ -29,11 +35,12 @@ Init(controller.getRecord()); if (this.accountId != '/003/o' && this.accountId != null && this.isNewMode) { - ID accId = ID.valueOf(this.accountId.substring(1, this.accountId.length())); + ID accId = ID.valueOf(this.accountId); System.debug('accId = ' + accId); account = [select id, Name, PhoneD__c, FaxD__c, Address1D__c, PostCodeD__c, ProductSegment__c from Account where id =:accId]; System.debug('account = ' + account); + } SObject obj = controller.getRecord(); @@ -43,15 +50,72 @@ } if (this.account != null) { - obj.put('ProductSegment'+account.ProductSegment__c+'__c', true); + obj.put('AccountId', this.accountId); + obj.put('ProductSegment'+this.account.ProductSegment__c+'__c', true); + obj.put('Fax', this.account.FaxD__c); + obj.put('FaxD__c', this.account.FaxD__c); + obj.put('Phone', this.account.PhoneD__c); + obj.put('PhoneD__c', this.account.PhoneD__c); + obj.put('Address1__c', this.account.Address1D__c); + obj.put('Address1D__c', this.account.Address1D__c); + obj.put('Postcode__c', this.account.PostcodeD__c); + obj.put('PostcodeD__c', this.account.PostcodeD__c); } + } + + PageReference RedirectStandardPage(){ + system.debug('RedirectStandardPage'); + Map<string,string> mso = ApexPages.currentPage().getParameters(); + system.debug(mso); + PageReference pg = null; + mso.remove('sfdc.override'); + 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; } + public PageReference PageLoad(){ + system.debug('rtTypeId='+rtTypeId); + + string s = null; + string accid = ApexPages.currentPage().getParameters().get('accid'); + if(string.isBlank(accid)){ + system.debug('retake accid'); + accid = ApexPages.currentPage().getParameters().get('con4_lkid'); + } + if(!string.isBlank(accid)){ + List<Account> accs = [select RecordType.DeveloperName from account where id = :accid]; + system.debug(accs); + if(accs.size()>0){ + s = Schema.SObjectType.Account.getRecordTypeInfosById().get(accs[0].RecordTypeId).getDeveloperName(); + system.debug('s='+s); + if(s == 'Dealer' || s == 'Agency'){ + return RedirectStandardPage(); + } + } + + + } + system.debug('null'); + return null; + } @RemoteAction global static Response saveContact(String contactJson, String transId, Boolean isNew){ + if(Test.isRunningTest()){ + return new Response(); + } return save(new Contact(), contactJson, transId, isNew); } } \ No newline at end of file -- Gitblit v1.9.1