| | |
| | | ApiPrefix:"{!ApiPrefix}", |
| | | SaveAndNew:false, |
| | | AWSToSobjectMap:{!AWSToSobjectMapJson}, |
| | | AWSToSobjectNonEncryptedMapKeySet:{!AWSToSobjectNonEncryptedMapKeySet}, |
| | | AWSToSobjectNonEncryptedMap:{!AWSToSobjectNonEncryptedMapJson}, |
| | | AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson}, |
| | | SobjectToAWSModel:function (sobjJson) { |
| | |
| | | queryBack:function (data) { |
| | | console.log('data = ' + data); |
| | | if(data.object){ |
| | | for(let f in config.AWSToSobjectNonEncryptedMap){ |
| | | let ele = GetEleByClass(config.ApiPrefix + "_"+ config.AWSToSobjectNonEncryptedMap[f]); |
| | | for(let fi in config.AWSToSobjectNonEncryptedMapKeySet){ |
| | | let f = config.AWSToSobjectNonEncryptedMapKeySet[fi]; |
| | | let ele = document.getElementById(api_id_map[config.AWSToSobjectNonEncryptedMap[f]]) |
| | | if(data.object.hasOwnProperty(f) && ele){ |
| | | |
| | | // 多选特殊处理 |
| | |
| | | ele.value = data.object[f]; |
| | | } |
| | | |
| | | if(ele.type.indexOf("select")>-1 && ele.value){ |
| | | jQuery(ele).change() |
| | | } |
| | | } |
| | | else{ |
| | | console.log(f + 'is not in data.object'); |
| | |
| | | return ''; |
| | | } |
| | | |
| | | function IsFormElement(tag_name){ |
| | | return ['input','select','textarea'].indexOf(tag_name)>-1; |
| | | function IsFormTag(tag_name){ |
| | | if (!tag_name) { |
| | | return false; |
| | | } |
| | | return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1; |
| | | } |
| | | |
| | | function IsFormElement(e){ |
| | | return IsFormTag(e.tagName); |
| | | } |
| | | |
| | | function getPIPayload(sobjJson) { |
| | |
| | | |
| | | function getSobjectInformation() { |
| | | |
| | | let nodelist = document.getElementsByClassName(config.ApiPrefix); |
| | | //let nodelist = document.getElementsByClassName(config.ApiPrefix); |
| | | let result = {} |
| | | for (let index = 0; index < nodelist.length; index++) { |
| | | let ele = nodelist[index]; |
| | | let field_api_name = GetEleApiName(ele); |
| | | for (let index in api_id_map) { |
| | | let ele = document.getElementById(api_id_map[index]); |
| | | let field_api_name = index; |
| | | let tag_name = ele.tagName.toLowerCase(); |
| | | if(!IsFormElement(tag_name)){ |
| | | if(!IsFormTag(tag_name)){ |
| | | console.log('tag_name='+tag_name+',field_api_name'+field_api_name+' is not a form element'); |
| | | continue; |
| | | } |
| | |
| | | //1. Get Sobject Information from Form |
| | | let sobjJson = getSobjectInformation(); |
| | | //2. Validate the Sobject field value formate, for example the email formate or phone formate |
| | | |
| | | let validationResultMessage = validateFieldValueFormate(); |
| | | console.log(validationResultMessage); |
| | | if (validationResultMessage) { |
| | | //Popup error message. - To Do After POC |
| | | alertErrorMessage(validationResultMessage); |
| | | return |
| | | } |
| | | //updated by Lijun0325 Start |
| | | //let validationResultMessage = validateFieldValueFormate(); |
| | | //console.log(validationResultMessage); |
| | | // if (validationResultMessage) { |
| | | // //Popup error message. - To Do After POC |
| | | // alertErrorMessage(validationResultMessage); |
| | | // return |
| | | // } |
| | | //updated by Lijun0325 End |
| | | // Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | |
| | | console.log(accountValue); |
| | | if(true || accountValue !='000000000000000'){ |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; |
| | | let searchContactKeyWord = document.querySelector("[data-id='Contact__c']").value; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue+"&searchContactKeyWord=" + searchContactKeyWord; |
| | | let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no'; |
| | | newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam); |
| | | if (window.focus) { |
| | |
| | | </apex:pageBlockSection> |
| | | </apex:repeat> |
| | | <script> |
| | | var init_nodes = document.getElementsByClassName("PIBackApi"); |
| | | var api_id_map={}; |
| | | for(let ei in init_nodes){ |
| | | let e = init_nodes[ei]; |
| | | if(IsFormElement(e)){ |
| | | if(e.getAttribute("multiple") != 'multiple' || e.style.display == 'none' && e.id.indexOf('selected') < 0){ |
| | | api_id_map[GetEleApiName(e)] = e.id; |
| | | } |
| | | |
| | | } |
| | | } |
| | | console.log(api_id_map); |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | |
| | | jQuery('option').each(function(i,e){ |
| | | if(e.value == '_\x01_'){ |
| | | e.value = ''; |
| | | } |
| | | }) |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | |
| | |
| | | } |
| | | jQuery('a[data-id="OwnerId"]').remove(); |
| | | |
| | | /* |
| | | jQuery(".lookupInput").each(function(i,e){ |
| | | let je =jQuery(e).find('input'); |
| | | je.attr("readonly",""); |
| | |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | });*/ |
| | | let previous_value = {}; |
| | | jQuery(".lookupInput input").each(function(i,e){ |
| | | let je =jQuery(e); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if(['Contact__c'].indexOf(dataid) < 0) return; |
| | | |
| | | jQuery(e).focus(function(){ |
| | | previous_value[this.id] = this.value; |
| | | }) |
| | | |
| | | jQuery(e).change(function(){ |
| | | if (previous_value[this.id] != jQuery(this).val()) { |
| | | document.getElementById(this.id+'_lkid').value = ''; |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |