| | |
| | | </style> |
| | | |
| | | <script> |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | AWSService.sfSessionId = '{!GETSESSIONID()}'; |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | var staticResourcesContact = JSON.parse('{!staticResourceContact}'); |
| | | var redirectMode = 'Save';//1. Save 2. SaveAndNew |
| | | var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}'); |
| | | var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}'); |
| | | var VLookUpFields = new Set(['Hospital_Reference__c','Consum_Apply__c','Department_Class_Ref__c', 'Daily_Report__c', 'OwnerId','Hospital_Department__c', |
| | | 'Competition_Company_Name__c','Report_OPDPlan__c','Loaner_request_no1__c','Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c', |
| | | 'Practitioner5__c','Opportunity1__c', |
| | | 'Opportunity2__c','Product01__c','Product1__c','Product2__c','Product3__c','Product4__c','Product5__c','Order_No__c','Person_In_Charge__c']); |
| | | // var VLookUpFields = new Set(['Hospital_Reference__c','Consum_Apply__c','Department_Class_Ref__c', 'Daily_Report__c', 'OwnerId','Hospital_Department__c', |
| | | // 'Competition_Company_Name__c','Report_OPDPlan__c','Loaner_request_no1__c','Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c', |
| | | // 'Practitioner5__c','Opportunity1__c','Responsible_Person__c', |
| | | // 'Opportunity2__c','Product01__c','Product1__c','Product2__c','Product3__c','Product4__c','Product5__c','Order_No__c','Person_In_Charge__c','CIC_Number__c']); |
| | | var VLookUpFields = {! VLookUpFieldsJson}; |
| | | var closeField = ''; |
| | | // var myCkeditor = null; |
| | | // try { |
| | |
| | | let result = {} |
| | | result.RecordTypeId = '{!rtTypeId}'; |
| | | for (let index = 0; index < nodelist.length; index++) { |
| | | if (VLookUpFields.has(nodelist[index].getAttribute("data-id"))) { |
| | | let tag_name = nodelist[index].tagName.toLowerCase(); |
| | | if(tag_name == 'div'){ |
| | | console.log(nodelist[index]) |
| | | } |
| | | if (VLookUpFields.indexOf(nodelist[index].getAttribute("data-id")) >= 0) { |
| | | console.log(nodelist[index].id.indexOf('lkwgt')); |
| | | if (nodelist[index].id.indexOf('lkwgt') == -1) { |
| | | let vlookUpNodeId = nodelist[index].id + '_lkid'; |
| | | let vlookUpNodeValue = document.getElementById(vlookUpNodeId).value; |
| | | result[nodelist[index].getAttribute("data-id")] = vlookUpNodeValue; |
| | | if (tag_name == 'div') { |
| | | vlookUpNodeId = nodelist[index].id.substring(0,nodelist[index].id.length-4) + '_lkid'; |
| | | } |
| | | let vlookUpNodeValue = document.getElementById(vlookUpNodeId); |
| | | let v = ''; |
| | | if(vlookUpNodeValue){ |
| | | v = vlookUpNodeValue.value; |
| | | }else{ |
| | | v = nodelist[index].value; |
| | | } |
| | | result[nodelist[index].getAttribute("data-id")] = v; |
| | | } |
| | | } else if (nodelist[index].type == 'checkbox') { |
| | | result[nodelist[index].getAttribute("data-id")] = nodelist[index].checked; |
| | |
| | | function checkRequiredFieldMsg(formData) { |
| | | let blankRequiredFields = ''; |
| | | for(i = 0;i<requiredFieldAPIList.length;i++){ |
| | | if (formData[requiredFieldAPIList[i]] && !VLookUpFields.has(requiredFieldAPIList[i])) { |
| | | if (formData[requiredFieldAPIList[i]] && (VLookUpFields.indexOf(requiredFieldAPIList[i]) == -1)) { |
| | | continue; |
| | | }else if(VLookUpFields.has(requiredFieldAPIList[i]) && formData[requiredFieldAPIList[i]] != '000000000000000'){ |
| | | }else if((VLookUpFields.indexOf(requiredFieldAPIList[i]) != -1) && formData[requiredFieldAPIList[i]] != '000000000000000'){ |
| | | continue; |
| | | }else{ |
| | | if(blankRequiredFields == ''){ |
| | |
| | | if (!tag_name) { |
| | | return false; |
| | | } |
| | | return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1; |
| | | return ['input','select','textarea','div'].indexOf(tag_name.toLowerCase())>-1; |
| | | } |
| | | |
| | | function IsFormElement(e){ |
| | |
| | | if('{!rtTypeId}'){ |
| | | payloadJson.RecordTypeId = '{!rtTypeId}';//Add by Li Jun for Record Type Issue 20220421 |
| | | } |
| | | if('{!isCloneMode}' == 'true'){ |
| | | var reportId = '{!sfRecordIdForEdit}'; |
| | | var r = sforce.connection.query("select Practitioner4__c,Practitioner5__c from Report__c where id='"+reportId+"'") |
| | | payloadJson.Practitioner4__c = r.getArray("records")[0].Practitioner4__c |
| | | payloadJson.Practitioner5__c = r.getArray("records")[0].Practitioner5__c |
| | | payloadJson.Id = null |
| | | } |
| | | return payloadJson; |
| | | } |
| | | |