I have the following JavaScript to show/hide sections in a tab based on the option set selection and I'm getting three errors when loading the form and when trying to change the option set selection. Can anyone please help me determine where I'm going wrong? I have applied the event as an On Change to the option set field.
Thank you very much
function HideOrShowSectionBasedOnoptionSetValue(){
var value = Xrm.Page.getAttribute("new_testrequesttype").getValue();
if(value!=null){
if(value == 100000000){
Xrm.Page.ui.tabs.get("Test Request").sections.get("Lab Test Request").setVisible(true); //Shows section 1
Xrm.Page.ui.tabs.get("Test Request").sections.get("Application Test Request").setVisible(false); //Hides section 2
}
else if(value == 100000001){
Xrm.Page.ui.tabs.get("Test Request").sections.get("Lab Test Request").setVisible(false); //Hides section 1
Xrm.Page.ui.tabs.get("Test Request").sections.get("Application Test Request").setVisible(true); //Shows section 2
}
On form load:
Error 1:
One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: 'ShowHideTestTabs' is not defined at eval code (eval code:1:1)
Error 2:
One of the scripts for this record has caused an error. For more details, download the log file.
TypeError: Unable to get property 'Initialize' of undefined or null reference at eval code (eval code:1:1)
When the option set selection is changed:
Error 3:
One of the scripts for this record has caused an error. For more details, download the log file.
SyntaxError: Expected ';' at RunHandlerInternal
*This post is locked for comments
Hi,
Error 1:
ShowHideTestTabs is undefined so I can not see any such keywords in your code so this is coming from another function.
Error 2:
Andrew already suggested that last closing bracket is missing and that's why function is not getting in on change. Seems due to that you are getting error 3.
Error 3:
Same reason of error 2.
Check your section "Name" by double clicking section property and put the correct name.
Martha,
Inside both tabs and sections properties you can find "Name" and "Label". You should use value from "Name" field in your scripts. I believe you used value from "Label" because value in "Name" can't contain spaces.
Also it seems that you missed one closing curly bracket - }
André Arnaud de Cal...
292,111
Super User 2025 Season 1
Martin Dráb
230,934
Most Valuable Professional
nmaenpaa
101,156