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 AX (Archived)

how to write x++ code(method) on Forms?

(0) ShareShare
ReportReport
Posted on by

 Whenever user select field CANType 6 from the drop-down list, the RF Serial#, Daughter Bd #, Rev, and Daughter serial # fields must be disabled. How do I achieve this result?  Any help would be greatly appreciated. Thanks all :D

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    vikram.dax Profile Picture
    5 on at

    Write If condition on CanType that control name

    for example

    If(ddl.cantype.value=can6)

    {

    RfSerial#.disabled();

    ...........

    ...........

    .............

    }

    Check the code once, May be the Syntax  Are Different...........

  • Community Member Profile Picture
    on at

    so CANType field> method> new method or override method>? and if it's override method then which override method?

    thanks :D

  • Verified answer
    Martin Dráb Profile Picture
    239,645 Most Valuable Professional on at

    If all fields are bound to a datasource, do it in this way:

    1. Override modified() method of the datasource field which "CAN type" is bound to.
    2. Implement the condition.
    3. Implement the following logic for all three fields (to be called when the condition is met):

      FormDataObject dsField = yourTable_ds.object(fieldNum(YourTable, TheField));
      dsField.allowEdit(conditionMet);
      dsField.skip(!conditionMet);
      // It's Best Practice to prefer allowEdit + skip before enabled(false)
    4. Typically, you want to call the same logic when user activates an existing record, i.e. in active() method.

    If the fields are not bound to a datasource, you'll do something similar directly with form controls.

  • Suggested answer
    Community Member Profile Picture
    on at

    you should write you code on the modify of the field 'CAN type'

    and you will required to write the code to disable the field in Active method of the record datasource on the form

    Code required to write in above methods will be to disable the field. for this purpose you will be required to Set the Autodeclaration property of the fields to Yes

    Please verify.

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans