Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

data validation by certain number of digits

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I need to create a numerical field with 13 characters long. But need validation so that users cannot incorrectly add any number that is too long or too short.  is there any OOTB validation we can added with this field? 

Thanks!

  • Verified answer
    Fubar Profile Picture
    Fubar 2,752 on at
    RE: data validation by certain number of digits

    You could also achieve the same by using an existing PCF Control 'input mask' on the form attribute (i.e. without JavaScript)

    docs.microsoft.com/.../additional-controls-for-dynamics-365-for-phones-and-tablets

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: data validation by certain number of digits

    Hi Ivy,

    you need to write the simple javascript without that it is not possible OOB.

    function Validation(executionContext) {
        var formContext = executionContext.getFormContext();
        var test = formContext.getAttribute("new_test1").getValue();
        var control = formContext.getControl("new_test1");
        if (test !== "") {
            if (isNaN(test)) {
                control.setNotification("Please enter only numbers", "CHKNUM");
            }
            else if (test.length != 13) {
                control.setNotification("Please enter only 13 characters", "CHKNUM");
            }
            else{
                control.clearNotification("CHKNUM");
            }
        }
    }

    You can refer following link to add the JS to form.

    https://reenhanced.com/2019/how-to-get-started-with-form-scripts-in-dynamics-365/

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans