web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Prevent required field error message coming up before save

(0) ShareShare
ReportReport
Posted on by 3,079

I have some situations where I have filtered lookups (i.e. lookup B has its values filtered based on the value of an earlier lookup A).  However, OOTB, if you change A, B keeps its value, which is likely no longer a valid combination with A.

So I added javascript onChange of A to clear out B - basically reset it, so the user now has to pick a valid option from B.  This works fine, except that - since B is a required field - the user sees the red circled "X" along with "You must provide a value" on B as soon as they change A.  I don't like the user experience of giving them an error before they've had a chance to do the thing that would prevent the error.  I'd like to suppress this warning until it's relevant, which is when they're trying to save.  Any idea why it comes up before save, and how to suppress/clear it until then?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi Allison,

       What about using javascript to turn off the field requirement for lookup B when OnChange of lookup A happens? You could then turn it back on with javascript in the OnSave event, and it would then flag them at that point if they didn't select something for lookup B.

    Hope that helps.

    John

  • awalters Profile Picture
    3,079 on at

    Thanks for the idea!  My concern, though, is that it then removes the visual cue for the user that they need to enter that field, which could also cause confusion.  Unless I also in JS just add in the asterisk manually, but I'm not sure if that's possible in a supported way (cause the only way I can think of requires DOM manipulation.  Not a big JS expert, though, so definitely could be missing an option).

  • Community Member Profile Picture
    on at

    You could set to "recommended" which would give the little '+' sign next to the field (instead of the asterisk). Not sure if that is exactly what you want, but may be as close as you can get without manipulating the DOM.

  • Verified answer
    am462 Profile Picture
    110 on at

    One option you have is to add Xrm.Page.getAttribute("attributeName").setRequiredLevel("none"); at the beginning of your onChange method and then Xrm.Page.getAttribute("attributeName").setRequiredLevel("required"); at the end of it. It seems to not show the red cross until you actually focus on the field and then click/tab away.

  • awalters Profile Picture
    3,079 on at

    *facepalm*  Makes sense.  Threw in a check to see if the field is required or not before setting/unsetting, since this is a generic function I'm using in a few places, but of course that works.  I was focused on clearing the error message itself somehow, rather than just sidestepping.  Thanks!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans