Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

Powerapps solution checker use strict issue

Posted on by 1,760

Hi Guys

I'm using 'use strict' in every function in a JavaScript file but the solution checker will still pick up a medium severity issue i.e. Use strict mode when possible. How do i go about making this go away? Or is this a known issue. 

  • Suggested answer
    Joe Crockett Profile Picture
    Joe Crockett 20 on at
    RE: Powerapps solution checker use strict issue

    I know this is an ancient question by the standard of this board, but I thought I'd share for the future: the solution checker warns you when you're not using "use strict" --- AND when you're using it incorrectly.

    I had thrown a bunch of "use script"s in there to make it go away -- and still failed. I used JSHint in VSCode, which highlighted my unnecessary ones, and when I removed the unnecessary ones, the "web use strict" warning went away.

  • Tiago Ruivo Profile Picture
    Tiago Ruivo 40 on at
    RE: Powerapps solution checker use strict issue

    I just tested that on the beginning of the script, and inside the function. Both failed. The error keeps poping. Any suggestions at this point?

    Thanks

  • Verified answer
    Johnny Yun Profile Picture
    Johnny Yun 455 on at
    RE: Powerapps solution checker use strict issue

    Hi Tia,
    This is one known issue.

    How do you enable strict mode?

    Simple. Toss this at the top of a program to enable it for the whole script:

    "use strict";

    Or place it within a function to turn on strict mode only within that context.

    function imStrict(){
      "use strict";
      // ... your code ...
    }

    ECMAScript 5 Strict Mode: https://johnresig.com/blog/ecmascript-5-strict-mode-json-and-more/
    Currently you have to 'use strict' within every new function  But not at top level.

    function imStrict(){
      "use strict";
      // ... your code ...
    }

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/374113/why-does-solution-checker-not-recognize-use-strict-in-the-beginning-of-a-javascript-webresource
    If you still met the issue please raise one ticket for escalation. Appreciate.

    Following doc list the MS Best practice rules used by solution checker
    https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/use-powerapps-checker#best-practice-rules-used-by-solution-checker
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode
    Strict mode is a way to introduce better error-checking into your code. Code should run in strict mode wherever possible. This is a JavaScript warning.
    Add use strict to the JavaScript file, this link explains it more detail
    According to this article it Strict mode helps :
    It catches some common coding bloopers, throwing exceptions.
    It prevents, or throws errors, when relatively “unsafe” actions are taken (such as gaining access to the global object).
    It disables features that are confusing or poorly thought out.
    Should you use single or double quotes e.g.
    ‘use strict’;
    or
    “use strict”;
    In JavaScript, it doesn’t matter if you use single or double quotes, here for more details
    To invoke use strict for the whole file, place it before any other JavaScript statements. It’s possible to apply use strict for specific functions.
    Reference Blog:https://crmbusiness.wordpress.com/2020/01/16/what-the-solution-checker-does-and-why-you-should-use-it/
    H
    ope above would hlep.

    Regards

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,252 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,089 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans