Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Make Field in Form Mandatory

(0) ShareShare
ReportReport
Posted on by

Hi Community,

in my PriceTable I have set the Mandatory Property for ModelId-Field to No.

In my Form Prices, when I set the Fields Vehicle Type and Vehicle Categorie (Except for "Non-Specified", I want the ModelId Field to become Mandatory.

Any Recommendations on how I could do that ?

I thought maybe I write Code in my validateWrite Method of the table, that when those two fields are set, then ModelId has to become mandatory.
But in that case, I heard it is not good on tablelevel to swtich from mandatory No to Yes .

PriceTableMakeModelIdMandatory.PNG

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Make Field in Form Mandatory

    MandatoryFieldInForm.PNG

    Thanks, I addressed the fields just like You said. And it works.

    However, it works that the Model Id field becomes mandatory.

    Also for records I had entered earlier and even for the VehicleType "Truck".... which doesn't actually make sense, since it is not part of my if-clause!!

    But how would it be possible, that the ModelId field for past records will not be marked as mandatory ?(as marked in the screenshot)

    And how can I only select that the edited or basically new record I am working on, that that ModelId shall become mandatory if the if-clause happens to be true ?

    If this Approach of mine is not good, will not be made in usual by the AX-Developers and could be handled much easier, and becomes way to complex or confusing please then let me know, so I can become better and efficient.

    Thanks in advance.

  • Suggested answer
    Ajit Profile Picture
    8,755 on at
    RE: Make Field in Form Mandatory

    Why don't you use datasource.fieldName like SYCFMPriceTable.SYCFMVehicleCategorie  == value.

  • Community Member Profile Picture
    on at
    RE: Make Field in Form Mandatory

    4571.Form3.PNG

  • Community Member Profile Picture
    on at
    RE: Make Field in Form Mandatory

    I am having hard time in addressing the fields or basically the formControl.

    if (SYCFMPriceTable_ds.object(fieldNum(SYCFMPriceTable, SYCFMVehicleTyp::Car)))

    it is giving me syntax error! just as for the other field, which is not an enum.

    i(SYCFMPriceTable_ds.object(fieldNum(SYCFMPriceTable, SYCFMVehicleCategorie == "Non-Specified")))

    How do I address those fields in my form correct ?

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: Make Field in Form Mandatory

    You may solve this issue in two steps

    1) implement condition on active() method of form data-source

    If(Vehicle Type and Vehicle Categories)

    {

     //Set any field mandatory

    }

    else

    {

    //set non-mandatory

    }

    2) implement same logic on table ValidatWrite()

    Step#2 will make sure that data entry from table level gets correct.

    Please note that if you are using any data entity for DIXF, you would need to see how you want to handle the situation with use of DIXF  

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans