In Dynamics 365, when a developer publishes a customization, users may see a page refresh. This piece of code appears to be specific to using legacy forms.
We will demo this with the Account form. Go to the account, and press F12 to open the developer tools:
Search for _metadatacacheversion:
Open the JsProvider.ashx version (other files may run during other circumstances). Click the curly braces to Pretty Print the file so it is readable:
Now, where the _metadatacacheversion line is, add a breakpoint in that block:
Now make an update to the account and save it. The debugger breakpoint will be hit. You will see the $v_A and $v_B variables are being set:
In the console, check the values. I have:
$v_A
5041419
Mscrm.InlineEditDataService.get_$1Y()
5041419
$v_B
“5511504”
Mscrm.InlineEditDataService.get_$1n()
“5511504”
You can see in the code, a comparison is done to see if any values have changed by comparing against two functions.
Now, let’s make a code update. I will add a field to a form, save and publish:
Now change a value on the account form (without refreshing the form) and save. The debugger will hit the breakpoint and you will see the values for our variables have changed:
As a result, you will see window.location.reload(true) run and the form will try to reload:
You will see a message like, “Changes you made may not be saved”:
Clicking Reload will reload the page and grab the latest changes from the server.
As noted, when using legacy forms this appears to be more obvious.
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL