You can use the tab change event when you want to change the source “scr” property of an IFRAME within the tab. If you set the IFrame.src property in the OnLoad event for an IFRAME within a collapsed tab, the value will be overwritten when the tab is expanded.
Using TabStateChange client API reference to add an event handler –
This event occurs when the DisplayState of the tab changes due to user interaction or when the setDisplayState method is applied in code.
tabObj.addTabStateChange(myFunction);Adds a function to be called when the TabStateChange event occurs.
Validate the changes in Dynamics 365 form –
Once the above code has been deployed, navigate to the Dynamics 365 and validate if the Tab State Change event works as expected.