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 :
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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans