I have a form where all sections are hidden by default. Depending on the value of a field, one of the sections is shown. When an action is taken in that section by clicking an HTML button in a web resource, some fields and the button in the section are hidden while other fields are shown, the form is set to inactive, saved and refreshed. At this point everything displays correctly.
However, when I refresh the form again, all of the visibility changes I made are reversed. I can't find anything in my code that could be doing this onLoad unless the setVisible function for a section also restores all the components within that section to their default visibility. I've also removed the part of my code in the onLoad section below and set all my sections as shown by default. This issue still persists.
Here are the relevant portions of my code:
onLoad:
... var tabObj = window.parentFormContext.ui.tabs.get("General"); var sectionRFI = tabObj.sections.get("RFI INFO"); var sectionGI = tabObj.sections.get("GENERAL INQUIRY INFO"); var sectionCV = tabObj.sections.get("PERSONAL CAMPUS VISIT INFO"); var sectionSMS = tabObj.sections.get("SMS RESPONSE"); var engagementType = window.parentFormContext.getAttribute("new_engagementtype").getValue(); switch (engagementType) { case 100000000: sectionRFI.setVisible(true); if (window.parentFormContext.getAttribute('new_rfiinternationalrequest').getValue()) { window.parentFormContext.getControl('new_rfiinternationalrequest').setVisible(true); window.parentFormContext.getControl('new_rfiinternationalrequestemailrecord').setVisible(true); window.parentFormContext.ui.quickForms.get('ContactsMailingAddress').setVisible(false); window.parentFormContext.getControl('WebResource_ebiprintlabelbutton').setVisible(false); } break; case 100000001: sectionGI.setVisible(true); break; case 100000002: sectionCV.setVisible(true); break; case 100000003: sectionSMS.setVisible(true); break; default: break; };
onClick:
const today = new Date(); window.parentFormContext.getAttribute('new_rfilabelprinteddate').setValue(today); window.parentFormContext.getControl('new_rfilabelprinteddate').setVisible(true); window.parentFormContext.getControl('WebResource_ebiprintlabelbutton').setVisible(false); deactivateForm();
deactivateForm:
window.parentFormContext.getAttribute('statecode').setValue(1); window.parentFormContext.data.refresh(true);