I think there is a bug with the TabStateChange customization in CRM 2016. I am posting this here so I can refer to it from the Dynamics CRM Connect forum. The formatting is much better here!
Does anyone else have this issue?
Scenario:
I have this javascript
function tabStateChange(context) { var formTab = context.getEventSource(); console.log("tabname: " + formTab.getName() + " DisplayState: " + formTab.getDisplayState()); }
Configured on this tab event
Assume the tab is customized to be expanded by default.
In CRM 2011, I click the tab to collapse it, and I get a console log that says "tabname: SUMMARY DisplayState: collapsed" as expected. I click again to expand it, the log text says expanded. That is correct.
In CRM 2016, same code and same configuration as 2011, when I click to collapse the already expanded tab, the log text says "tabname: SUMMARY DisplayState: expanded". I expect it to say collapsed. When I click the collapsed tab, the event fires and the log text says collapsed instead of expanded. This seems wrong.
It seems in CRM 2016, it seems the TabStateChange javascript does not get executed after the tab control state is updated. I could just remember that formTab.GetDisplayState() called in the event actually means the opposite of what it returns, but that is wrong.