Skip to main content

Notifications

Dynamics 365 general forum
Suggested answer

Custom JS not working as it must work

Posted on by 337

Hi,

I am currently managing a D365 instance, which is designed by someone else without proper documentation. So right now I am in the middle of nowhere. However, I am moving the scripts from Xrm. Page to contextual form concept which is a tedious task. I am facing so many issues while doing this simple to look migration. For example, I am just writing a simple piece of code (see below for code reference) and getting an error. Can someone please help me with that?

function accountFormOnLoad(executionContext) {

   debugger;

   var formContext = executionContext.getFormContext(); // get formContext

   formContext.ui.clearFormNotification("1000");

   var id = formContext.data.entity.getId();

/*    if (id === "") return;

   var agreementArray = [];*/

   var level = "Info";

   var message = "Active agreement " + "00738" + ": Callouts used day = " + "4" + " and night = " + "2";

   /*if (id !== undefined) {*/

       formContext.ui.setFormNotification("Hello", "Warning", id);

   /*}*/

}

Error Message:

pastedimage1601653034800v1.jpeg

Log File:

UciError: Invalid value Warning for notificationLevel
at i (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at p (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at S (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at wewillfixitsandbox.crm4.dynamics.com/.../8.js
at wewillfixitsandbox.crm4.dynamics.com/.../app.js
at wewillfixitsandbox.crm4.dynamics.com/.../app.js
at l._executeInternal (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at l.execute (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at v.execute (wewillfixitsandbox.crm4.dynamics.com/.../app.js
at ee.setFormNotification (wewillfixitsandbox.crm4.dynamics.com/.../8.js

  • Suggested answer
    RE: Custom JS not working as it must work

    Hello Waleed, 

    Thank you for your post on the community Forum. 

    The issue is related to the level set, it should be WARNING not Warning.

    formContext.ui.setFormNotification("Hello", "WARNING", id);

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-ui/setformnotification

    pastedimage1601875977933v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Give Back to the Community this Month

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,135 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans