Upon form load, I check the type of the form and dynamically load the appropriate form based on that. It was working fine, but when the form reloads to the new form, I encounter a "JavaScript" error which says "cannot execute code from freed script" in English.
Here is the snippet of code that I am using:
avento_customertypecodeChange = function () {
var lblShow = "information";
var picklistName = Xrm.Page.getAttribute("customertypecode").getSelectedOption().text.toLowerCase();
if (picklistName.contains("hc")) {
lblShow = "information hc";
}
else {
lblShow = "information";
}
var newIndex = -1;
var currentName = Xrm.Page.ui.formSelector.getCurrentItem().getLabel().toLowerCase();
if (currentName != lblShow) {
Xrm.Page.ui.formSelector.items.forEach(function (item, index) {
var itemLabel = item.getLabel().toLowerCase();
if (itemLabel == lblShow) {
newIndex = index;
}
});
}
if (newIndex != -1) Xrm.Page.ui.formSelector.items.get(newIndex).navigate();
}
Both forms are using the same "JavaScript" file. Could this be causing the error? How can I resolve this issue and avoid the error? I have been trying to find a solution for hours, but haven't had any luck. I'm hoping someone has encountered this problem before and can provide assistance.