Skip to main content

Notifications

Dynamics 365 general forum
Answered

How to show an alert message when the maximum text limit of a field reaches

Posted on by 1,017

Hi, we have a requirement to show an alert message when use enters the maximum length of the field that it is set to.

We have a multiple lines of text field and its limit we have currently set to is 5000 characters and when users reaches 5000 characters, I want to show an alert message. Please advise how can this be achieved.Thanks.

  • Verified answer
    Steve Zhao2 Profile Picture
    Steve Zhao2 on at
    RE: How to show an alert message when the maximum text limit of a field reaches

    Hi James,

    You could change the control of multiple lines of text field, such as change it to Rich Text Editor Control.

    pastedimage1668134407572v1.png

    And if users reach 5000 characters, it will automatically alert this error message:

    pastedimage1668134620317v2.png

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: How to show an alert message when the maximum text limit of a field reaches

    Hi,

    Try below code

    function AlertWhenLengthExceeded(executionContext)

    {

    Var formContext= executioncontext.getFormContext();

    Var value = formContext.getAttribute("yourfieldschemanane").getValue();

    if(value.length>500)

    alert("your message");

    }

    Add this function on onchange of your field

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,469 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans