| | |
| | | <!-- |
| | | @description : |
| | | @author : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | @group : |
| | | @last modified on : 03-08-2022 |
| | | @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | --> |
| | | <apex:page standardController="Order" extensions="NewAndEditOrderController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script> |
| | |
| | | } |
| | | return result; |
| | | } |
| | | function QuerySobjectFromAWS() { |
| | | function QuerySobjectFromAWS(EndUserLkid) { |
| | | if(EndUserLkid){ |
| | | //query contact |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | let result = sforce.connection.query("SELECT AWS_Data_Id__c from Contact where id = '" + EndUserLkid + "'"); |
| | | let records = result.getArray("records"); |
| | | let awsDataId = records[0].AWS_Data_Id__c; |
| | | let queryContactBack = function(data){ |
| | | console.log('ContactData = ' + data.object);//To Do later |
| | | document.querySelector("[data-id='EndUser__c']").value = data.object.lastName; |
| | | unblockUI(); |
| | | } |
| | | AWSService.query(staticResourcesContact.queryUrl, awsDataId, queryContactBack, staticResources.token); |
| | | } |
| | | AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token); |
| | | } |
| | | function queryBack(data) { |
| | |
| | | // Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | | alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult); |
| | | alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult); |
| | | return |
| | | } |
| | | // //3. Prepare the payload for New PI API To AWS - To Do |
| | |
| | | } |
| | | if (accountValue != ''){ |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; |
| | | let searchContactKeyWord = document.querySelector("[data-id="+field+"]").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) { |
| | |
| | | accountValue = ForeignTradeCompanyValue; |
| | | } |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; |
| | | let searchContactKeyWord = document.querySelector("[data-id="+field+"]").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) { |
| | |
| | | } |
| | | if (accountValueD != ''){ |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD; |
| | | let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&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) { |
| | |
| | | accountValueD = ForeignTradeCompanyDValue; |
| | | } |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD; |
| | | let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&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) { |
| | |
| | | } |
| | | } else { |
| | | let baseUrl = "/apex/SearchContactPage"; |
| | | let suffixUrl = "?contactId="+contactNodeId; |
| | | let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; |
| | | let suffixUrl = "?contactId="+contactNodeId+"&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) { |
| | |
| | | if (null != newSearchContactWindow) { |
| | | newSearchContactWindow.close(); |
| | | } |
| | | if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){ |
| | | if (null != newSearchContactWindow) { |
| | | newSearchContactWindow.close(); |
| | | } |
| | | let contactInfoStr = document.getElementById('page:form:contactId').value; |
| | | console.log('closePopup:'+contactInfoStr); |
| | | let contactInfo = JSON.parse(contactInfoStr); |
| | | let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; |
| | | document.getElementById(contactNodeId).value = contactInfo.ContactId; |
| | | document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; |
| | | } |
| | | if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){ |
| | | if (null != newSearchContactWindow) { |
| | | newSearchContactWindow.close(); |
| | | } |
| | | let contactInfoStr = document.getElementById('page:form:contactId').value; |
| | | console.log('closePopup:'+contactInfoStr); |
| | | let contactInfo = JSON.parse(contactInfoStr); |
| | | let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; |
| | | document.getElementById(contactNodeId).value = contactInfo.ContactId; |
| | | document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; |
| | | } |
| | | // if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){ |
| | | // if (null != newSearchContactWindow) { |
| | | // newSearchContactWindow.close(); |
| | | // } |
| | | // let contactInfoStr = document.getElementById('page:form:contactId').value; |
| | | // console.log('closePopup:'+contactInfoStr); |
| | | // let contactInfo = JSON.parse(contactInfoStr); |
| | | // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; |
| | | // document.getElementById(contactNodeId).value = contactInfo.ContactId; |
| | | // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; |
| | | // } |
| | | // if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){ |
| | | // if (null != newSearchContactWindow) { |
| | | // newSearchContactWindow.close(); |
| | | // } |
| | | // let contactInfoStr = document.getElementById('page:form:contactId').value; |
| | | // console.log('closePopup:'+contactInfoStr); |
| | | // let contactInfo = JSON.parse(contactInfoStr); |
| | | // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; |
| | | // document.getElementById(contactNodeId).value = contactInfo.ContactId; |
| | | // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; |
| | | // } |
| | | let contactInfoStr = document.getElementById('page:form:contactId').value; |
| | | console.log('closePopup:'+contactInfoStr); |
| | | let contactInfo = JSON.parse(contactInfoStr); |
| | | let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; |
| | | document.getElementById(contactNodeId).value = contactInfo.ContactId; |
| | | document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; |
| | | } |
| | | |
| | | |
| | |
| | | <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> |
| | | <h2 class="mainTitle">{! SobjectLabel}<apex:outputText rendered="{!isNewMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode)}">{!$Label.Edit}</apex:outputText></h2> |
| | | </td> |
| | | <td class="pbButton" id="topButtonRow"> |
| | | <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 0.4;"> |
| | | <input class="btn" type="Button" value="{!$Label.Save}" onclick="saveSobjectProcess()" /> |
| | | <input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess(1)" /> |
| | | <apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" /> |
| | |
| | | |
| | | <!--Each section has layoutFields, let's iterate them as well--> |
| | | <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField"> |
| | | <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" |
| | | required="{!layoutField.isRequired}" /> |
| | | <!-- <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" |
| | | required="{!layoutField.isRequired}" /> --> |
| | | <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}" |
| | | required="{!layoutField.isRequired}" /> |
| | | <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}" |
| | | required="{!layoutField.isRequired}" /> |
| | | <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}" |
| | | /> |
| | | <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}"> |
| | | </apex:pageblocksectionitem> |
| | | </apex:repeat> |
| | |
| | | } |
| | | console.log(api_id_map); |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | let e = document.querySelector("[data-id='"+layoutField.fieldAPI+"']"); |
| | | e.disabled = !(layoutField.editableField); |
| | | if (!(layoutField.editableField)) { |
| | | if (e.getAttribute("multiple") && e.getAttribute("multiple") == 'multiple') { |
| | | e.parentNode.classList.add("disabledbutton"); |
| | | } |
| | | if (e.tagName == 'DIV') { |
| | | e.classList.add("disabledbutton"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | | console.log('Mode for Sobject Page:' + {!isNewMode}); |
| | | var EndUserLkid = '000000000000000'; |
| | | if(document.querySelector("[data-id='EndUser__c']")){ |
| | | EndUserLkid = document.getElementById(document.querySelector("[data-id='EndUser__c']").id + '_lkid').value; |
| | | } |
| | | if (!{!isNewMode}) { |
| | | blockme(); |
| | | QuerySobjectFromAWS(); |
| | | if(EndUserLkid!='000000000000000'){ |
| | | QuerySobjectFromAWS(EndUserLkid); |
| | | }else{ |
| | | QuerySobjectFromAWS(); |
| | | } |
| | | |
| | | } |
| | | |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); |
| | | document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); |
| | | // document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); |
| | | // document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); |
| | | |
| | | |
| | | document.getElementById('topButtonRow').style = ''; |
| | | document.getElementById('bottomButtonRow').style = ''; |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | <tr> |
| | | <td class="pbTitle"> |
| | | <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> </td> |
| | | <td class="pbButtonb" id="bottomButtonRow"> |
| | | <td class="pbButtonb" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;"> |
| | | <input class="btn" type="Button" value="{!$Label.Save}" onclick="saveSobjectProcess()" /> |
| | | <input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess()" /> |
| | | <apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" /> |