Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

formContext.getControl(arg).addNotification(notification): "Error loading control"

(0) ShareShare
ReportReport
Posted on by 5

I was able to set a "recommendation" notification on my field as you can see on the left of the label on the first image and it works fine. But when actions are added, this error pops up and replaces the full field (Second image).

1.

pastedimage1584044105405v2.png

2.

pastedimage1584044357259v3.png

The error log shows "Cannot read property 'message' of undefined"

This is the code I'm using to generate the notification as per the documentation:

let temp: Function[] = null;
var actionCollection: Xrm.actionsObject = {
    message: "See duplicate contacts?",
    actions: temp
};

actionCollection.actions = [function () {
    console.log("works!");
}];

formContext.getControl("my_field").addNotification({
    messages: ["Title"],
    notificationLevel: "RECOMMENDATION",
    uniqueId: "potential_duplicate_contact",
    actions: actionCollection
});

I've tried multiple different variations of this code and always still the same error.

It seems like this feature is not completely done for the new UI? It also looks quite different from the old when it works. The documentation mentions it should show an "i" symbol and yet the symbol is a light-bulb. The icon is now on the left of the label instead of the field.

  • anonsgate Profile Picture
    422 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    change

    actions: actionCollection

    to

    actions: [actionCollection]

  • Gabriel F Profile Picture
    5 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    I have tried this and the same error still appears. It was worth a shot.

  • Suggested answer
    Marco.P Profile Picture
    2,405 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    I've just noted that in your code you miss the clearNotification, maybe that's why your error shows up when actions are added.

    try this

    actionCollection.actions = [function () {
        console.log("works!");

    formContext.getControl("my_field").clearNotification("potential_duplicate_contact");


    }];

  • Gabriel F Profile Picture
    5 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    Alright so there's some good news and some bad news. Good news is that recommendations on business rules work as they should. Bad news is that we require to fetch data from a related entity to make our recommendation, which you can't do with business rules.

    In the end I don't think we'll go with the recommendation route since the UI seems a bit awkward and not the most noticeable.

    Regardless of my decision, I still think this is something that should be looked at to make sure this is or isn't a bug that will need to be addressed.

    Gabriel

  • Gabriel F Profile Picture
    5 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    Thanks for the quick response Marco. I will try the business rule as you have suggested and will get back to you after.

  • Marco.P Profile Picture
    2,405 on at
    RE: formContext.getControl(arg).addNotification(notification): "Error loading control"

    Hi,

    i will dig deep into this (and test the js code), in the meantime i can suggest you to try to achieve the same result with a business rule

    (wich i already used for case like this with no issue at all)

    https://community.dynamics.com/crm/b/magnetismsolutionscrmblog/posts/how-to-use-recommendations-in-dynamics-365-business-rules

    I think it's Worth a try !

    Marco

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 91

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans