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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

JS onLoad form notification help (only show when field contains data)

(0) ShareShare
ReportReport
Posted on by

Hi all,

I'm trying to show a form notification when a specific field on the form contains data.

I'm not good with Javascript, but have pieced together the below:

function ResellerAlert(executionContext) {

    var formContext = executionContext.getFormContext();

    var reseller = formContext.getAttribute("parentaccountid");

    if (reseller != null) {

        formContext.ui.setFormNotification("This account has a Reseller listed, please check before quoting.""WARNING");

    }

}


The problem I have is that the notification shows all the time. Even if the 'reseller' field is empty


The 'reseller' field is a lookup field to another account.


What am I doing wrong?

I have the same question (0)
  • Suggested answer
    barryjarvis Profile Picture
    on at

    I've discovered what was wrong.

    for anybody searching this in future, i was missing 'getvalue()' from the 'getAttribute()' function.

    new code as below:

    function ResellerAlert(executionContext) {

       var formContext = executionContext.getFormContext();

       var reseller = formContext.getAttribute("parentaccountid").getValue();

       if (reseller != null) {

           formContext.ui.setFormNotification("This account has a Reseller listed, please check before quoting.", "WARNING");

       }

    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 60 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans