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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Setting mandatory field by code is not working as expected

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

When i set a field as mandatory by code, the red star appears but it still allows me to save without it being filled

if(//)
{
Field1.mandatory(true);
}
else
{
Field1.mandatory(false);
}

I have the same question (0)
  • Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Are you this on a table extension or your custom table ?

    Share the actual code with us.

  • junior AX Profile Picture
    1,552 on at

    Hi Komi,

    This is on a form and field1 is a control with lookup but it's not bound to any datasource

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, I think unbound fields cannot be changed to mandatory. Even though it will show red line and feels it is mandatory but it's not.

    There is a feature to make field required by personalization but won't recommend if required for all users as user can disable it and moreover personalizationn has to be used by all users.

    dynamicspedia.com/.../

  • Suggested answer
    Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Hello Junior AX,

    Just like Mohit said, I doubt you will get the result using .mandatory.

    You check if the field is empty and throw an error yourself. 

    Check this.

    community.dynamics.com/.../want-to-mandatory-display-unbound-field

  • André Arnaud de Calavon Profile Picture
    303,446 Super User 2026 Season 1 on at

    Hi junior AX,

    A small addition to the comments above. Mohit shared my blog. Also, the option described in this blog is not working for unbound controls.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 517 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 440

#3
Adis Profile Picture

Adis 266 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans