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)

FormDataSource - AllowEdit()

(0) ShareShare
ReportReport
Posted on by

Hi Community,

following Scenario:

I have a table with two fields: firstname and lastname.

I made a form for it, set the DataSource in the Design to "Table5" (tablename) and dragged the fields...

In the Code (Screenshot) I set that my firstname shall not be edited, but in the form or table it still can be edited!

What is the Problem with my code ? or did I place the code not correctly ? I wrote the code in the Forms Method.

4426.forCommunity.PNG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi Khashayar G ,

    If you want to disable edit on this field permanently, set property "AllowEdit" and "AllowEditOnCreate" to "No" on the Table field itself.

    If you want to do it in the runtime via code then you need to call your new "allowEdit" method, because AX won't call it for you. You can add a call to active() method of the form datasource, it is called by AX each time you highlight a record in a grid or you can add it to init() method, that is called only one, when you open the form.

  • Community Member Profile Picture
    on at

    Ok I will do it.

    Then, my allowEdit() is right ?

    You said "You can add a call to active() of the form datasource" , where do I make that call ?

    I don't have to override my active() I guess, but do I have to make a new Method in the

    Table5 DataSource, where I call the active() ?

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Your method will disable the field. "allowEdit" is quite a generic name, I would rename it to "allowEditFIrstName".

    You have to override  active() method and call your method there, AX will call active() for you whenever user select a record in a grid, so don't worry about calling active() manually.

  • Jie G Profile Picture
    Microsoft Employee on at

    You need to call your code to disable editing during form's built-in methods. You can check the inheritance of FormRun to get more details.

  • Community Member Profile Picture
    on at

    For now I am lacking in the Code.

    I want to overwrite my active() ad call allowEditFirstName, but I am lacking.

    I can't call it with this.allowEditFirstName.´

    I have to do more.

    I Need a Connection to the Form which I called "Form5".

    I just Need to find a way how to call the method which I wrote in Form5.

    Do You have a good tip on how I can call the allowEditFirstName() in the active() ?

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    I'm not quite sure why do you have a problem here. Just type element.allowEditFirstName(); after super() in active method of form data source, something like:

    public int active()

    {

       int ret = super();

       element.allowEditFirstName();

       return ret;

    }

  • Verified answer
    startax Profile Picture
    1,845 on at

    HI

    As ievgen Miroshnikov suggested you can create new method allowEditFirstName() and write your code to allow edit false.

    public int active()

    {

       int ret = super();

       element.allowEditFirstName();

       return ret;

    }

    Or you can directly write

    public int active()

    {

       int ret = super();

       table_ds.object(fieldnum(table, field1)).allowedit(false);

       return ret;

    }

  • Community Member Profile Picture
    on at

    Amazing, thanks to both of You.

    Unfortunately I wasn't Aware of "element". I tried it with "this" and I tried several other Things ........................... but nothing worked.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans