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?

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,393 User Group Leader on at
    RE: Custom attributes in fields in an entity

    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

       }

    }

  • Sunayana Profile Picture
    47 on at
    RE: Custom attributes in fields in an entity

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

    Here, 140 is static.

  • Suggested answer
    Ak Negi Profile Picture
    320 on at
    RE: Custom attributes in fields in an entity

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,238 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans