| | |
| | | }else{ |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | } |
| | | |
| | | AssignValueFromUrl(ApexPages.currentPage().getParameters(),obj); |
| | | |
| | | PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobjectTypeValue); |
| | | //layoutEncryptedAPIList = piIntegration.PIFields; |
| | | encryptedAPIList = piIntegration.PIFields; |
| | |
| | | SaveAndNewButtonUrl = String.format('/setup/ui/recordtypeselect.jsp?ent={0}&retURL=/{1}/o&save_new_url=/{1}/e?retURL=%2F{1}%2Fo', new String[]{sobjectTypeValue,sobjectPrefix}); |
| | | } |
| | | |
| | | system.debug('piIntegration.PIDetails='+piIntegration.PIDetails); |
| | | for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) { |
| | | |
| | | AWSToSobjectNonEncryptedMap.put(PIDetail.AWS_Field_API__c, PIDetail.SF_Field_API_Name__c); |
| | |
| | | System.debug(new List<string>(AWSToSobjectNonEncryptedMap.keySet())); |
| | | system.debug('AWSToSobjectNonEncryptedMapJson='); |
| | | system.debug(AWSToSobjectNonEncryptedMapJson); |
| | | system.debug('AWSToSobjectEncryptedMap='+AWSToSobjectEncryptedMap); |
| | | try{ |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, sobjectTypeValue,'classic'); |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | |
| | | layoutEncryptedAPIList = piIntegration.PIFields; |
| | | system.debug('Exception from get layout service:'+e.getmessage()); |
| | | } |
| | | } |
| | | |
| | | // 从url参数赋值到当前页面 |
| | | public static void AssignValueFromUrl(Map<string,string> mso, sobject sobj){ |
| | | |
| | | String sobject_name = sobj.getSObjectType().getDescribe().getName(); |
| | | Map<string,object> temp = new Map<string,object>(); |
| | | Map<string,FieldDefinition> fdm = new Map<string,FieldDefinition>(); |
| | | List<FieldDefinition> fds = [SELECT Id, DurableId, QualifiedApiName,ValueTypeId , EntityDefinitionId, NamespacePrefix,EntityDefinition.NamespacePrefix, DeveloperName, MasterLabel, Label FROM FieldDefinition where EntityDefinition.QualifiedApiName = :sobject_name]; |
| | | for(FieldDefinition fd : fds){ |
| | | //system.debug(fd.DurableId); |
| | | fdm.put(fd.DurableId.split('\\.')[1],fd); |
| | | } |
| | | |
| | | for(string key : mso.keySet()){ |
| | | if (key.toLowerCase() == 'id') { |
| | | System.debug('skip id assign'); |
| | | continue; |
| | | } |
| | | string new_key = key; |
| | | system.debug('new_key='+new_key); |
| | | if(new_key.contains('_lkid')){ |
| | | new_key = new_key.replace('_lkid', ''); |
| | | new_key = new_key.substring(2); |
| | | }else{ |
| | | if(temp.containsKey(new_key)){ |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | system.debug('now new_key='+new_key); |
| | | if(fdm.containsKey(new_key)){ |
| | | system.debug('fdm.get(new_key)='+fdm.get(new_key)); |
| | | string val_str = mso.get(key); |
| | | system.debug('val_str='+val_str); |
| | | /*无需做decode,sf内部已经做好 |
| | | try{ |
| | | val_str = EncodingUtil.urlDecode(mso.get(key),'UTF-8'); |
| | | }catch(Exception e){ |
| | | continue; |
| | | system.debug('Exception from get Key:'+e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | } */ |
| | | object val = null; |
| | | string type_id = fdm.get(new_key).ValueTypeId; |
| | | // address, boolean, date, datetime, double, id, location, string, time |
| | | if(string.isBlank(val_str)){ |
| | | val = null; |
| | | }else if(type_id == 'boolean'){ |
| | | if(val_str == '1'){ |
| | | val = true; |
| | | }else{ |
| | | val = boolean.valueOf(val_str); |
| | | } |
| | | }else if(type_id == 'date'){ |
| | | // |
| | | try{ |
| | | val = date.parse(val_str); |
| | | }catch(Exception e){ |
| | | system.debug('val_str='+val_str); |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | try{ |
| | | val = date.valueOf(val_str); |
| | | }catch(Exception ee){ |
| | | system.debug('val_str='+val_str); |
| | | system.debug(ee.getMessage()); |
| | | system.debug(ee.getStackTraceString()); |
| | | continue; |
| | | } |
| | | } |
| | | }else if(type_id == 'datetime'){ |
| | | // |
| | | try{ |
| | | val = datetime.parse(val_str); |
| | | }catch(Exception e){ |
| | | system.debug('val_str='+val_str); |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | try{ |
| | | val = datetime.valueOf(val_str); |
| | | }catch(Exception ee){ |
| | | system.debug('val_str='+val_str); |
| | | system.debug(ee.getMessage()); |
| | | system.debug(ee.getStackTraceString()); |
| | | continue; |
| | | } |
| | | } |
| | | }else if(type_id == 'double' || type_id == 'number'){ |
| | | try{ |
| | | val = decimal.valueOf(val_str.replace(',', '')); |
| | | }catch(Exception ee){ |
| | | system.debug('val_str='+val_str); |
| | | system.debug(ee.getMessage()); |
| | | system.debug(ee.getStackTraceString()); |
| | | continue; |
| | | } |
| | | |
| | | }else if(type_id == 'id' || type_id == 'string'){ |
| | | val = val_str; |
| | | }else{ |
| | | system.debug('type_id='+type_id+' is not support to convert'); |
| | | continue; |
| | | } |
| | | temp.put(fdm.get(new_key).QualifiedApiName,val); |
| | | }else{ |
| | | system.debug(key+' is not in fdm'); |
| | | } |
| | | } |
| | | |
| | | for(string key : temp.keySet()){ |
| | | system.debug('assign '+key+'='+temp.get(key)); |
| | | try{ |
| | | sobj.put(key, temp.get(key)); |
| | | }catch(Exception e){ |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static boolean IsCurrentUserAdministrator() |
| | | { |
| | | return IsAdministrator(UserInfo.getUserId()); |
| | | } |
| | | |
| | | |
| | | public static boolean IsAdministrator(Id user_id) |
| | | { |
| | | return IsAdministrator(new List<id>{user_id}).get(user_id); |
| | | } |
| | | |
| | | public static Map<id,boolean> IsAdministrator(List<id> user_ids) |
| | | { |
| | | Map<id,User> pfs = new Map<id,User>([select id from User where id in :user_ids and profileid in ( SELECT profileId FROM PermissionSet WHERE IsOwnedByProfile = true AND IsCustom = false and permissionsmanageusers = true)]); |
| | | |
| | | Map<id,boolean> res = new Map<id,boolean>(); |
| | | for(Id uid: user_ids){ |
| | | res.put(uid, pfs.containsKey(uid)); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | public static string GetReferenceField(string f){ |
| | |
| | | Map<String, Schema.SObjectField> fieldAPIToTypeMap = leadSchema.getDescribe().fields.getMap(); |
| | | Map<String,Object> fieldValueMap = (Map<String,Object>)JSON.deserializeUntyped(leadJson); |
| | | |
| | | string rtid = null; |
| | | if (fieldValueMap.containsKey('RecordTypeId')) { |
| | | rtid = String.valueOf(fieldValueMap.get('RecordTypeId')); |
| | | } |
| | | List<string> invalid_fields = GetInvalidFieldFromLayout(rtid,sobjectTypeValue); |
| | | |
| | | Boolean isClone = false; |
| | | //2. Save Record Process |
| | |
| | | |
| | | for (String fieldAPI: fieldValueMap.keySet()) { |
| | | system.debug('field API='+fieldAPI); |
| | | |
| | | if(invalid_fields.contains(fieldAPI) && !IsCurrentUserAdministrator()){ |
| | | system.debug(fieldAPI+' is invalid'); |
| | | continue; |
| | | } |
| | | |
| | | if(!fieldAPIToTypeMap.containskey(fieldAPI)){ |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static List<string> GetInvalidFieldFromLayout(string rtid, string sobject_name){ |
| | | |
| | | List<Metadata.LayoutSection> sections = MetaDataUtility.GetRecordTypePageLayout(rtid, sobject_name); |
| | | List<string> ls = new List<string>(); |
| | | if (sections == null) { |
| | | System.debug('sections=null'); |
| | | return ls; |
| | | } |
| | | |
| | | system.debug(Json.serialize(sections)); |
| | | |
| | | for (Metadata.LayoutSection section : sections) { |
| | | if (section.layoutColumns != null) { |
| | | for (Metadata.LayoutColumn layoutColumn : section.layoutColumns) { |
| | | if(layoutColumn.layoutItems != null){ |
| | | for (Metadata.LayoutItem item : layoutColumn.layoutItems) { |
| | | |
| | | System.debug(item); |
| | | if(item.field==null)continue; |
| | | if (item.behavior == Metadata.UiBehavior.READONLY ) { |
| | | ls.add(item.field); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | return ls; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | // 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'); |
| | | system.debug('mso='+ApexPages.currentPage().getParameters()); |
| | | this.accountId = ApexPages.currentPage().getParameters().get('accid'); |
| | | if(string.isBlank(this.accountId)){ |
| | |
| | | } |
| | | |
| | | 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(){ |
| | |
| | | |
| | | @RemoteAction |
| | | global static Response saveContact(String contactJson, String transId, Boolean isNew){ |
| | | if(Test.isRunningTest()){ |
| | | return new Response(); |
| | | } |
| | | return save(new Contact(), contactJson, transId, isNew); |
| | | } |
| | | } |
| | |
| | | } |
| | | static testMethod void NewAndEditContactController() { |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | Contact con = TestDataUtility.CreateContacts(1)[0]; |
| | | // Contact con = TestDataUtility.CreateContacts(1)[0]; |
| | | Account acc = TestDataUtility.CreateAccounts(1)[0]; |
| | | Contact con = new Contact(); |
| | | String url = ApexPages.currentPage().getParameters().put('retURL','/'+acc.Id); |
| | | |
| | | Test.startTest(); |
| | | ApexPages.StandardController sc = new ApexPages.StandardController(con); |
| | |
| | | String qisJson = '{"AccountId":"0010l00001Q1r4e","OwnerId":"0050l0000061MOe","Department":"","MobilePhone":"***********","Title":"","Phone":"","Salutation":"","LastName":"***","Fax":"","ContactEnglishName__c":"","OtherPhone":"","ManagementCode_Ext__c":"","Email":"*****@company.com","isBatch__c":false,"TechnicalServiceCreated__c":false,"IsNew__c":false,"isServiceCreate__c":false,"Postcode__c":"**********","Address1__c":"**********","Address2__c":"","Address3__c":"","EnglishAddress__c":"","ProductSegmentBS__c":false,"ProductSegmentRVI__c":false,"ProductSegmentIE__c":false,"ProductSegmentNDT__c":false,"ProductSegmentANI__c":false,"StatusD__c":"Draft","ContactStatus__c":"Active","CancelReason__c":"","Remark__c":"","Phone_Encrypted__c":"","OtherPhone_Encrypted__c":"","MobilePhone_Encrypted__c":"64bd0db056d0bfd21fae76cc5dbdf4d1","PhoneD_Encrypted__c":null,"OtherPhoneD_Encrypted__c":null,"MobilePhoneD_Encrypted__c":null,"Email_Encrypted__c":"68fda69bb586ec70073b015fbff6c19420b838c523e79c9737c6fe095fd5cc55","EmailD_Encrypted__c":null,"FaxD_Encrypted__c":null,"Address3D_Encrypted__c":null,"Address1D_Encrypted__c":null,"Address3_Encrypted__c":"","Address2D_Encrypted__c":null,"Address1_Encrypted__c":"2df1bc4bf3800c5e05e3d9f394c3446567d1f05482d2295650b7b50e9e4aa97a92338985c9693f576e1e6df667aaee46","EnglishAddress_Encrypted__c":"","ContactEnglishName_Encrypted__c":"","Title_Encrypted__c":"","TitleD_Encrypted__c":null,"PostcodeD_Encrypted__c":null,"Postcode_Encrypted__c":"ecec26168c09cf090b8b4a95ca524a61","LastName_Encrypted__c":"dcce196c4cfc273a83777852ddd486ab","PhoneD__c":null,"OtherPhoneD__c":null,"MobilePhoneD__c":null,"EmailD__c":null,"FaxD__c":null,"Address3D__c":null,"Address2D__c":null,"Address1D__c":null,"TitleD__c":null,"PostcodeD__c":null,"AWS_Data_Id__c":"962006242048344064"}'; |
| | | NewAndEditContactController.saveContact(qisJson,'avgwshDFcxAS',False); |
| | | NewAndEditContactController.saveContact(qisJson,'avgwshDFcxAS',True); |
| | | |
| | | qis.PageLoad(); |
| | | Test.stopTest(); |
| | | } |
| | | /*static testMethod void testMethod3() { |
| | | |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | // Contact contactTest = TestDataUtility.CreateContacts(1)[0]; |
| | | Account acc = TestDataUtility.CreateAccounts(1)[0]; |
| | | //Account acc1 = [SELECT Id,Name FROM Account WHERE RecordType.DeveloperName = 'Office' OR RecordType.DeveloperName = 'AgencyContact' OR RecordType.DeveloperName = 'Agency' Limit 1]; |
| | | String accrecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); |
| | | Account acc1 = new Account(Name = 'testacc1',RecordTypeId = accrecordTypeId); |
| | | insert acc1; |
| | | |
| | | |
| | | String recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Account').getRecordTypeId(); |
| | | String url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId); |
| | | url = ApexPages.currentPage().getParameters().put('accid',acc1.Id); |
| | | url = ApexPages.currentPage().getParameters().put('con4_lkid',acc1.Id); |
| | | |
| | | Test.startTest(); |
| | | ApexPages.StandardController con = new ApexPages.StandardController(new Contact()); |
| | | NewAndEditContactController cont = new NewAndEditContactController(con); |
| | | // cont.rtTypeId |
| | | |
| | | cont.PageLoad(); |
| | | Test.stopTest(); |
| | | }*/ |
| | | } |
| | |
| | | PIIntegration piIntegration = new PIIntegration(); |
| | | //查询url |
| | | System.debug('thhsobjectType = ' + sobjectType); |
| | | // PI_Policy_Configuration__c config = [SELECT Full_New_URL__c,Full_New_Encrypt_URL__c,Full_Update_Encrypt_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,Full_View_Unified_Contact_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType]; |
| | | PI_Policy_Configuration__c config = [select Full_New_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c from PI_Policy_Configuration__c where Sobject_Type__c =: sobjectType]; |
| | | PI_Policy_Configuration__c config = [SELECT Extra_Info__c,Full_New_URL__c,Full_New_Encrypt_URL__c,Full_Update_Encrypt_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType]; |
| | | //PI_Policy_Configuration__c config = [select Full_New_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c from PI_Policy_Configuration__c where Sobject_Type__c =: sobjectType]; |
| | | System.debug('thhconfig = ' + config); |
| | | |
| | | //获取appid和appsecret |
| | |
| | | |
| | | //获取敏感字段 |
| | | // piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c,PI_Policy_Configuration__r.Full_New_Encrypt_URL__c,PI_Policy_Configuration__r.Full_Update_Encrypt_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true]; |
| | | piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true]; |
| | | piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true order by Order_Number__c]; |
| | | List<String> vLookUpFields = new List<String>(); |
| | | List<String> PIFields = new List<String>(); |
| | | for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) { |
| | |
| | | piIntegration.queryUrl = config.Full_Read_URL__c; |
| | | piIntegration.deleteUrl = config.Full_Delete_URL__c; |
| | | piIntegration.undeleteUrl = config.Full_Undelete_URL__c; |
| | | // piIntegration.viewUnifiedContactUrl = config.Full_View_Unified_Contact_URL__c; |
| | | // piIntegration.newEncryptUrl = config.Full_New_Encrypt_URL__c; |
| | | // piIntegration.updateEncryptUrl = config.Full_Update_Encrypt_URL__c; |
| | | piIntegration.extraInfo = config.Extra_Info__c; |
| | | piIntegration.newEncryptUrl = config.Full_New_Encrypt_URL__c; |
| | | piIntegration.updateEncryptUrl = config.Full_Update_Encrypt_URL__c; |
| | | piIntegration.transactionURL = config.TransactionURL__c; |
| | | piIntegration.hostUrl = awsConfiguration.Host_URL__c; |
| | | piIntegration.searchUrl = config.Full_Search_URL__c; |
| | |
| | | public String queryUrl{set;get;} |
| | | public String deleteUrl{set;get;} |
| | | public String undeleteUrl{set;get;} |
| | | public String viewUnifiedContactUrl{set;get;} |
| | | public String extraInfo{set;get;} |
| | | public String newEncryptUrl{set;get;} |
| | | public String updateEncryptUrl{set;get;} |
| | | public String hostUrl{set;get;} |
New file |
| | |
| | | <!-- |
| | | @description : |
| | | @author : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | @group : |
| | | @last modified on : 02-22-2022 |
| | | @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | --> |
| | | <apex:page standardController="Contact" extensions="NewAndEditContactController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:form id="form"> |
| | | <apex:pageblock id="pageBlock"> |
| | | <apex:pageBlockSection showHeader="false" title="" collapsible="true" columns="2" id="pageBlockSection"> |
| | | <!--Each section has layoutFields, let's iterate them as well--> |
| | | <!-- <apex:repeat value="{!layoutEncryptedAPIList}" var="encryptedAPI"> |
| | | <apex:outputField html-data-id="{!encryptedAPI}" title="{!ApiPrefix}{!encryptedAPI}" value="{!Contact[encryptedAPI]}" /> |
| | | </apex:repeat> --> |
| | | <apex:outputField html-data-id="{!encryptedAPIList[0]}" title="{!ApiPrefix}{!encryptedAPIList[0]}" value="{!Contact[encryptedAPIList[0]]}" /> |
| | | <br/> |
| | | <!-- Title --> |
| | | <apex:outputField html-data-id="{!encryptedAPIList[1]}" title="{!ApiPrefix}{!encryptedAPIList[1]}" value="{!Contact[encryptedAPIList[1]]}" /> |
| | | <apex:outputField html-data-id="{!encryptedAPIList[2]}" title="{!ApiPrefix}{!encryptedAPIList[2]}" value="{!Contact[encryptedAPIList[2]]}" /> |
| | | |
| | | <apex:outputField value="{!Contact.Title_IsChanged__c}" /> |
| | | <!-- Mobile Phone --> |
| | | <apex:outputField html-data-id="{!encryptedAPIList[3]}" title="{!ApiPrefix}{!encryptedAPIList[3]}" value="{!Contact[encryptedAPIList[3]]}" /> |
| | | <apex:outputField html-data-id="{!encryptedAPIList[4]}" title="{!ApiPrefix}{!encryptedAPIList[4]}" value="{!Contact[encryptedAPIList[4]]}" /> |
| | | |
| | | <apex:outputField value="{!Contact.MobilePhone_IsChanged__c}" /> |
| | | </apex:pageBlockSection> |
| | | <script> |
| | | var config = { |
| | | SobjectName : "{!SobjectName}", |
| | | ApiPrefix:"{!ApiPrefix}", |
| | | AWSToSobjectMap:{!AWSToSobjectMapJson}, |
| | | AWSToSobjectNonEncryptedMap:{!AWSToSobjectNonEncryptedMapJson}, |
| | | AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson} |
| | | }; |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | function QuerySobjectFromAWS() { |
| | | AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token); |
| | | } |
| | | var queryBack = function queryBack(data) { |
| | | if(!data.object){ |
| | | console.log('data.object is ' + data.object); |
| | | return; |
| | | } |
| | | |
| | | for(let f in config.AWSToSobjectNonEncryptedMap){ |
| | | let t = "[title='"+config.ApiPrefix+config.AWSToSobjectNonEncryptedMap[f]+"']"; |
| | | let ele = document.querySelector(t); |
| | | if(ele){ |
| | | ele.title = ''; |
| | | if(data.object.hasOwnProperty(f)){ |
| | | ele.innerHTML = data.object[f]; |
| | | } |
| | | else{ |
| | | console.log(f + 'is not in data.object'); |
| | | } |
| | | }else{ |
| | | console.log('selector='+t+' not found'); |
| | | } |
| | | |
| | | } |
| | | // 当不能自动正确替换加密数据时需要在此处添加js,硬编码处理 |
| | | // document.querySelector("[data-id='LastName']").value = data.object.lastName; |
| | | }; |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | console.log('sfdcPage.appendToOnloadQueue') |
| | | // document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[0].innerText = '姓名' |
| | | QuerySobjectFromAWS(); |
| | | }); |
| | | </script> |
| | | </apex:pageblock> |
| | | </apex:form> |
| | | </apex:page> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>54.0</apiVersion> |
| | | <label>ViewContactDecryptInfoForApproval</label> |
| | | </ApexPage> |