Can we enable and disable the Check box in a form using X++ class If yes please help with the code.
Yes, form controls are classes, therefore there is no other option than using the class. There is enabled() method for this purpose.
The important question is how you should get a reference to the checkbox, and unfortunately you didn’t give us any details about your situation…
If it’s an unbound controls, you can do this:
It depends on your particular situation, but most likely you’ll need to set AutoDeclaration to Yes on the form control.
If the control is bound to a data source, you should do this instead:
It may be a bit different if you, for example, write your code in an event handler method, but I can’t explain all possibilities. Next time, please give us more information, so we can talk about your particular problem.
Also, please don’t forget to attach a version tag (e.g. AX 2012 or D365FO) when creating a new thread.
Yeah, I would like Thank you for your suggestion from next time I will be adhere to them.
Below is my problem Details.
Check box is in Form (grid) and that is bound to a data-source IntegrationActivityTable and the Enum field is State.(Auto Declaration is Yes) and
As all (form,Table,field) a standard datasource I cannot change there itself so this is my doubt.
If it’s a bound field, you need my second code snippet. Don’t set AutoDeclaration=Yes, unless you need it for other purposes. If you change properties of the data source field, it’ll apply to all controls bound to this field, which is better then dealing with each control individually.
What exactly do you mean by “I cannot change there itself”?
Also, I still don’t see any information about the version. Don’t you mean that you’re talking about D365FO and you’re not familiar with extensions?
I am new to D365FO and I know extension some what. "I can’t change there itself " is I need to create extension of form(class) then i should add the code snippet.
Aha, so we’re indeed talking about D365FO. I’ve attached the tag to this thread.
Before you can an extension, you need to ask yourself when you want to execute your logic. Depending on the answer, you may want to subscribe to various events or extend different objects (the form, data sources or form controls).
Thank you for the Help.