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)

AllowEdit property of the control & ds field

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I have got a form that have got a MyFieldToEnable field that should not be editable. Also the form has got a enum-based control.
When the user changes the value of the enum-based control to certain value, then the fieldA should get editable.

I can put in the form init():

MyTable_ds.object(fieldnum(MyTable, MyFieldToEnable)).allowEdit(false);


and then in the modified of the MyTable.MyEnumFieldfield of the DS write

void modified()
{
     MyTable_ds.object(fieldnum(MyTable, MyFieldToEnable)).allowEdit(MyTable.MyEnumField== MyEnumField::CertainValue);
} 


, but on the control showing MyFieldToEnable field there is a property allowEdit. So instead of disabling the field on the init() I could just set allowEdit = false directly on the control and in the modified of the MyEnumField in DS  in this case write:

void modified()
{
 
    MyFieldToEnableControl.allowEdit(MyTable.MyEnumField== MyEnumField::CertainValue);
}


but I know it's not the best practice....

Why? What are the reasons for doing this on the control and minimising the number of lines of code to be written (that AX dev is aiming for usually)?

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    You're forgetting that a single field can be displayed in several controls, e.g. in a grid and on a details tab page. Changing one control wouldn't impact the other, while changes of DS fields propagates to all related controls.

    By the way, think about what will happen if MyTable.MyEnumField is already set to CertainValue when you open the form. With your logic, MyFieldToEnable will be read-only although it should be enabled. Also, if it's possible to switch to other records of MyTable, you'll have the same problem. To cover these cases, you should put the enabling/disabling logic to active() method of the datasource.

  • Community Member Profile Picture
    on at

    Thanks a lot Martin

    The second bit is not applicable in my case as requested form is designated for the new record creation and the status would never be CertainValue on opening, but it all makes sense of course what you've said.  

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ivan (Vanya) Kashperuk Profile Picture

Ivan (Vanya) Kashperuk 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans