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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

running Java Script notification when text field is blank

(0) ShareShare
ReportReport
Posted on by 8

I have a single line text field

I am trying to get a notification at the top of the form to say that the field is blank, if there is data in the field then i want the notification to disappear

I just cant get my code below to work, i keep getting an error




function setDocumentNotification() {
var ref_field = Xrm.Page.getAttribute("new_reference").getValue();
if(ref_field == "") {
Xrm.Page.ui.setFormNotification("Reference field is blank", "INFO");
}
else {
Xrm.Page.ui.clearFormNotification();
}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    What error you are getting ? can you please share .

    Do null check before check blank and use unique id se form notification and clear notification. Take a look below thread - 

    community.dynamics.com/.../setting-notification

  • Verified answer
    MohammadFaheemuddin1600 Profile Picture
    15 on at

    Hi,

    You need to set id for the setFormNotification and then you can use it to clear that...

    You can use it as below:

    if(ref_field==null){

    Xrm.Page.ui.setFormNotification("Value Cannot be empty", "Error", "1");

    }

    else{

    Xrm.Page.ui.clearFormNotification("1");

    }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans