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

Custom attributes in fields in an entity

(0) ShareShare
ReportReport
Posted on by 47

I have an entity which contains a field of type single line of text. Is it possible to add custom attribute to this field?

For example: I have Max length as an attribute of Single Line of Text Field. Is it possible to create another attribute Minimum length that takes the minimum number of characters to be entered in that field?

I have the same question (0)
  • Suggested answer
    Ak Negi Profile Picture
    320 on at

    Hi Sunayana

    For minimum length, you will have to write a javascript.

    please use following lines of code:

    function TemsAndCondtitionsValidation(Excontext)
    {
        var termsConds = Xrm.Page.getAttribute("new_termsconditions").getValue();
        if(termsConds.length < 140)   {
            Xrm.Utility.alertDialog("The length of characters entered are less than the minimum requirement of 140 characters");
            context.getEventArgs().preventDefault(); // cancel save
        }
    }

    Arun Singh Negi| Dynamic CRM Developer

    If this answer is helpful.Please Mark as Verified.

  • Sunayana Profile Picture
    47 on at

    But what If I want to take the minimum characters dynamically?

    Here, 140 is static.

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hi Sunayana,

    to achieve this dynamically, You can create another field(type: Whole Number) to maintain the minimum length for your field and you can fetch the length dynamically. Now, the Arun's JS will look like this:

    function TemsAndCondtitionsValidation(Excontext)

    {

     var termsConds = Xrm.Page.getAttribute("new_termsconditions").getValue();

    var minimumlength=Xrm.Page.getAttribute("new_minimumlength").getValue();

       if(termsConds.length < minimumlength)   {

           Xrm.Utility.alertDialog("The length of characters entered are less than the minimum requirement of "+minimumlength+" characters");

           context.getEventArgs().preventDefault(); // cancel save

       }

    }

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 165

#2
ManoVerse Profile Picture

ManoVerse 156 Super User 2026 Season 1

#3
Zhilan Profile Picture

Zhilan 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans