Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to prevent saving based on embedded data validation?

Posted on by Microsoft Employee

Hi Everyone,

I have two fields, text and number fields.

If I input "aaa" into text field and "bbb" into number field and put focus on other field, it will pop up an error message, like only numbers can be input into number fields.

BUT, what if I input "aaa" into text field and "bbb" into number field and I just click save

What I have is that error message popped up but form is saved also.

"aaa" is saved into text field.

My Question is how can I prevent text field saving action in this case?

BTW, I know I can use context.getEventArgs().preventDefault() for customized validation.

Thank you,

Kei

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to prevent saving based on embedded data validation?

    Thank you, Yadnyesh. I know I can do customized validation in JavaScript. As I mentioned, I don't want to do like this, since I need to code for several kinds of date type.

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to prevent saving based on embedded data validation?

    No. It is not given by system, but in JavaScript you can use regex. You should be able to get ready code on google.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to prevent saving based on embedded data validation?

    How? Is this provided by system?

  • Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to prevent saving based on embedded data validation?

    In that case there is other option than a custom JavaScript validation. You can check values against regular expressions to validate your data.

    Kindly mark verify answer if this resolves your problem.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to prevent saving based on embedded data validation?

    Thank you for your reply, Yadnyesh.

    I can do customized validation. But I need to add a lot of codes for Date, Number, Alphabets. I can't determine fields required or not.

    Is there any way I can get validation result from system?

    Thank you,

    Kei

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to prevent saving based on embedded data validation?

    EAny reason you don't want to go for customized validation using preventDefault?

    Also, if you make both fields required, then you should receive a message without saving values.

    Thanks and regards,

    Yadnyesh Kuvalekar

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to prevent saving based on embedded data validation?

    ...

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans