Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Custom attributes in fields in an entity

Posted on by 45

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
    Naveen Ganeshe 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
    Sunayana 45 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
    Ak Negi 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans