web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Custom JS not working as it must work

(0) ShareShare
ReportReport
Posted on by 347

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

I have the same question (0)
  • Suggested answer
    Jean Joel Kakou Profile Picture
    on at
    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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 74 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 55 Most Valuable Professional

#3
Anthony Blake Profile Picture

Anthony Blake 43 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans