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

Announcements

News and Announcements icon
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.

I have the same question (0)
  • Marco.P Profile Picture
    2,405 on at

    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

  • Gabriel F Profile Picture
    5 on at

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

  • Gabriel F Profile Picture
    5 on at

    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

  • Suggested answer
    Marco.P Profile Picture
    2,405 on at

    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

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

  • anonsgate Profile Picture
    422 on at

    change

    actions: actionCollection

    to

    actions: [actionCollection]

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
11manish Profile Picture

11manish 119

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans