| | |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | public static String sobjectTypeValue = 'Case'; |
| | | public Boolean isNewMode{set;get;} |
| | | public Boolean isCloneMode{protected set;get;} |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | | public String contactId{set;get;}//For Lookup field |
| | |
| | | public string AWSToSobjectEncryptedMapJson{get{return JSON.serialize(AWSToSobjectEncryptedMap);}} |
| | | public NewAndEditCaseController(ApexPages.StandardController controller) { |
| | | isNewMode = true; |
| | | isCloneMode = false; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | PIPL_Name_Label = Label.PIPL_Name_Label; |
| | | PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg; |
| | |
| | | //获取所有字段 |
| | | List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Case').getDescribe().fields.getMap().keyset()); |
| | | // Add fields to controller. This is to avoid the SOQL error in visualforce page |
| | | Map<string,string> mso = ApexPages.currentPage().getParameters(); |
| | | if(mso != null && mso.containsKey('newclone')){ |
| | | isCloneMode = true; |
| | | } |
| | | if (!Test.isRunningTest()) { |
| | | controller.addFields(fieldList); |
| | | } |
| | |
| | | contactsInfo = JSON.serialize(sfIdToAWSIdMap); |
| | | }else{ |
| | | //新建 |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | // rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | rtTypeId = mso.get('RecordType'); |
| | | obj.put('OwnerId',UserInfo.getUserId()); |
| | | } |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Case','classic'); |
| | |
| | | } |
| | | } |
| | | |
| | | System.debug('caseInfo='+caseInfo); |
| | | System.debug('caseInfo.Account__c='+caseInfo.Account__c); |
| | | if (!String.isBlank(caseInfo.ContactId) && (String.isBlank(caseInfo.Account__c) || Id.valueOf(caseInfo.Account__c).to15() =='000000000000000')) { |
| | | Contact c = [select id,AccountId from Contact where id = :caseInfo.ContactId]; |
| | | caseInfo.Account__c = c.AccountId; |
| | | if (Id.valueOf(caseInfo.ContactId).to15() !='000000000000000') { |
| | | Contact c = [select id,AccountId from Contact where id = :caseInfo.ContactId]; |
| | | caseInfo.Account__c = c.AccountId; |
| | | } |
| | | } |
| | | |
| | | //2. Save Record Process |
| | |
| | | Response resp = new Response(); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | String rid = ''; |
| | | String awsDataId = ''; |
| | | Boolean isClone = false; |
| | | try{ |
| | | System.debug('abcde'); |
| | | if(isNew){ |
| | | awsDataId = (String)caseInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | | Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId]; |
| | | |
| | | if(!isNew){ |
| | | isClone = cases.size() == 0; |
| | | } |
| | | if(isNew || isClone){ |
| | | System.debug('caseInfozhj = ' + caseInfo); |
| | | if(!Test.isRunningTest()){ |
| | | insert caseInfo; |
| | | } |
| | | }else{ |
| | | System.debug('into update'); |
| | | String awsDataId = (String)caseInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | | Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId]; |
| | | // String awsDataId = (String)caseInfo.get('AWS_Data_Id__c'); |
| | | // System.debug('awsDataId = ' + awsDataId); |
| | | // Case[] cases = [select id from Case where AWS_Data_Id__c =:awsDataId]; |
| | | System.debug('cases ========================= ' + cases); |
| | | System.debug('Cases[0].id = ' + cases[0].id); |
| | | caseInfo.put('Id',cases[0].id);//For testing; |