While updating all our javascript files for D365 CE (Online), I noticed we have many JS files that are not been called from the form events like OnSave, OnLoad or OnChange. These files are only been called from an internal references by other JS libraries.
Since these files are not been called on the form event, I have to pass the execution context when the function is called. (Which is don't prefer to do as it we I don't know how many other JS libraries are calling these functions. Only 1 solution is part of this sprint at the moment)
My question is, if I have a JS library that is loaded on the form first, and if this file have a global execution context, can I just use that in all the following JS libraries?
for example: JSFile1- Function XYZ(eContext) - Runs OnLoad of the form. (execution context passed as parameter)
JSFile2 - Function ABC() - NOT called from any form events but need execution context.
In JSFile1, I am declaring a global var eContext and initialising it within the XYZ(eContext) function.
Can I then use this global eContext var in any way in my JSFile2?