web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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  

  • Community Member Profile Picture
    on at

    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 ?

  • Community Member Profile Picture
    on at

    4571.Form3.PNG

  • Suggested answer
    Ajit Profile Picture
    8,755 on at

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

  • Community Member Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans