Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution checker complains about dg.xrmquery.web.js #292

Open
Mihails-Simvulidi opened this issue Aug 9, 2023 · 2 comments
Open

Solution checker complains about dg.xrmquery.web.js #292

Mihails-Simvulidi opened this issue Aug 9, 2023 · 2 comments

Comments

@Mihails-Simvulidi
Copy link

Mihails-Simvulidi commented Aug 9, 2023

Describe the bug
Power Apps solution checker shows a medium severity issues because:

  1. Deprecated Xrm.Page is used in dg.xrmquery.web.js.
  2. == and != are used for comparison instead of === and !==.

To Reproduce
Steps to reproduce the behavior:

  1. Run XrmDefinitelyTyped.exe.
  2. Create a TypeScript script which uses XrmQuery.
  3. Build and run webpack.
  4. Upload the generated JavaScript file to a new solution.
  5. Run the solution checker on this solution.

Expected behavior
No solution checker issues. It could be achieved by:

  1. Only including the code which uses Xrm.Page when using Dynamics 365 versions below 9.0 which do not support newer client API.
  2. Replacing == and != with === and !==.

Screenshots
Solution check results

Environment

  • CRM/D365/CDS version: 9.2.23074.00178
  • Tool version: 6.3.0
@Mihails-Simvulidi Mihails-Simvulidi changed the title Solution checker complains about Xrm.Page usage Solution checker complains about dg.xrmquery.web.js Aug 9, 2023
@skovlund
Copy link
Contributor

Hello @Mihails-Simvulidi

We've made an initial effort towards reducing the warnings produced by the solution checker by enforcing strict comparison in dg.xrmquery.web.js. However, the minified versions (dg.xrmquery.web.min.js and dg.xrmquery.web.promise.min.js) still produce warnings as the minifying process (gulp-uglify and UglifyJS) introduces loose equality comparisons.

Unfortunately I don't see a solution to all of the warnings produced by the solution checker:

  1. We still use Xrm.Page and Xrm.Page.context. These could strictly speaking be removed, as they are only called as a backup solution to getting the client url, when it can't be retrieved through neither global context nor utility. However, removing them is not backwards compatible, and would be breaking for anyone where this backup solution is used (I don't have the overview of where this may be the case). Generally speaking this would just require bumping the major/minor version number, but since this is buried quite deep in XrmQuery, I don't think everyone upgrading would notice this change before it became an issue.
  2. Compiling TypeScript can generate "use strict"; at file level of each JavaScript file but not at function level. I don't believe there are any recommendations for doing this differently. But currently the Solution Checker does not consider this behavior correct. The Solution Checker requires the "use strict;" line at the beginning of each function. Additionally it creates a warning for incorrect usage of "use strict"; which currently includes the line at file level. We could add "use strict"; to functions in TypeScript, but that doesn't improve the code, and I don't believe we can add it to helper functions generated by the TypeScript compiler, e.g. __extends.

I don't currently see a feasible solution for eliminating all Solution Checker warnings. Ideas are welcome and pull requests even more so.

@Mihails-Simvulidi
Copy link
Author

Thank you!

Regarding Xrm.Page - I think XrmDefinitelyTyped.exe could generate different dg.xrmquery.web*.js files depending on environment version or setting in XrmDefinitelyTyped.exe.config.

Regarding "use strict;" - maybe it could be reported as a bug to Microsoft?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants