Hi Glen
I have created a project that addresses all of these "headaches" so you don't have to. It uses the power of module bundling to bundle all of your code so you only have to deal with one file when you upload it to your d365 system while maintaining good code structure.
Please let me know if you have any questions.
https://github.com/rexkenley/d365js
------------------------------
Rex Kenley Tan, MCSA, MCSD
Minneapolis MN
https://www.youracclaim.com/users/rex-kenley-tan*Always be CURRENT with JavaScript & C#, NEVER be obsolete.
DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
------------------------------
Original Message:
Sent: May 01, 2020 11:35 AM
From: Glen Wolinsky
Subject: JS Code Spaces: Ribbon vs. Form
Daryl,
Thanks for your response. Over the past few days, I've been doing some experimentation with dependencies and js between the ribbon and main form. Here's what I found so far:
Setup
- Common js file: Library of commonly-used routines across entire Organization
- This file is referenced by main-form scripts and ribbon scripts
- Main js file: The js code that executes from the main form.
- Dependencies include:
- All non-displayed form fields that the script needs (avoids loading down form with a bunch of hidden fields)
- The common js file
- Ribbon js file: The js code that excutes to show/hide and execute buttons on the ribbon.
Discoveries
When loading the form in debug mode, I discovered a few things about how and where the js runs for both the ribbon and main form. Also, the dependencies have a nuance of which you should be aware.
- Scripts for ribbon run in one frame and scripts for the main form do indeed run in a separate frame.
- The ribbon script can successfully access the Common script which is only defined as a dependency in the Main script! Does this mean there is cross-frame scripting going on? I don't think so.
- Another thing is that all of the attribute dependencies defined on the Main script are accessible by the ribbon script.
- It seems that the ribbon doesn't cross frame boundaries but it DOES seem to read the main form dependencies and use them.
- The debug session revealed that the Common code file the ribbon was using was loaded into the Ribbon frame and was NOT being run from the Main form frame.
- NOTE: Trying to define attribute dependencies for the RIBBON script does not work! It seems you HAVE TO define any dependencies for the Ribbon to use by defining them in a script dependency on the main form or by actually including the field as hidden on the main form.
ANYONE: Please let me know if I'm on base here or horribly wrong. I want to get a handle on this as I am refactoring our system and want to keep my JS code files trim and organized.
Sincerely,
Glen Wolinsky
------------------------------
Glen Wolinsky
Lead Applications Developer
Miller & Martin PLLC
Chickamauga GA
Original Message:
Sent: Apr 21, 2020 08:14 AM
From: Daryl LaBar
Subject: JS Code Spaces: Ribbon vs. Form
As far as I know the ribbon and the form are actually different frames, and any sort of code that would work to call function of JS in another frame would not be supported code.
------------------------------
Daryl LaBar
President, MVP
Gap Integrity
Fishers IN
Original Message:
Sent: Apr 20, 2020 04:27 PM
From: Glen Wolinsky
Subject: JS Code Spaces: Ribbon vs. Form
I am in the process of a rewrite/refactor of my customizations, and I'm trying to make my JS loads as efficient as possible. My question has to do with the "space" in which my JS code runs in the Ribbon vs. the Main form.
If I load a code file with Method-X in the Ribbon, can the Main Form code files find Method-X without explicitly loaded the first code file again?
Thanks,
Glen
------------------------------
Glen Wolinsky
Lead Applications Developer
Miller & Martin PLLC
Chickamauga GA
------------------------------