Hi all,
I'm having a hard time with the following problem:
On a custom entity i'm using javascript to hide some sections based on a lookup (one remains visible the other sections are hidden). The javascript works perfectly (on change & on load) but when I save the record all the sections are visible again. After reloading the page it works fine again. I also tried to run the javascript after save but this was not the solution. The fields were visible after the first save and only when I clicked a second time on the save button the javascript worked again.
This is the javascript I use:
function hideProductSections(executionContext){
var formContext = executionContext.getFormContext();
var productId = formContext.getAttribute("bc_parentproduct").getValue();
var product;
if (productId != null) {
product = String(productId[0].id);
switch(product) {
case "{D614A830-F420-EC11-B6E6-6045BD8A193A}"://nen4400-1
formContext.ui.tabs.get("general").sections.get("nen4400-1").setVisible(true);
formContext.ui.tabs.get("general").sections.get("nen4400-2").setVisible(false);
break;
case "{63B28BC1-F420-EC11-B6E6-6045BD8A193A}"://nen4400-2
formContext.ui.tabs.get("general").sections.get("nen4400-1").setVisible(false);
formContext.ui.tabs.get("general").sections.get("nen4400-2").setVisible(true);
break;
default:
formContext.ui.tabs.get("general").sections.get("nen4400-1").setVisible(false);
formContext.ui.tabs.get("general").sections.get("nen4400-2").setVisible(false);
break;
}
}
else {
formContext.ui.tabs.get("general").sections.get("nen4400-1").setVisible(false);
formContext.ui.tabs.get("general").sections.get("nen4400-2").setVisible(false);
}
}
This is a short version, the switch contains more cases.
Hopefully someone can help me with this issue.
Thanks in advance!