Drop Dialog Form in Dynamics Ax 2012
In Ax 2012 there are many new form templates available. One of them i have widely used in my designs is the drop dialog. The drop dialog is very catchy little Form template that can create non intrusive UI for small updates/changes/inputs.
Here is a small picture of how a drop dialog will show up. (click on the image to open a gif Animation of the drop dialog)
In the standard you can find many places where the drop dialog boxes is put to use. The create planned order form in Master planning\Planned order is one nice example.
How to create a drop dialog button
1. Create a form from the Drop Dialog template
2. Create a menu item for this form
3. Add a “Drop Dialog button” in the form where you want to invoke it.
You are done with this beautiful little form:)
Creating Edit methods for DS that don’t allow editing in Dynamics ax – Followup
A while ago i made a post on allowing a edit method to work on a disabled datasource .. http://bit.ly/hZMBIW
I found a still better idea from one of the comments, this post is to highlight the comment.
I rather would loop trough all data source fields (FormDataObject) and set them allowEdit=false at initalization time of the form/ds. That’s more confortable for the user, because he sees, that he cannot modify other fields than the edit fields. – LuegisdorfOne suggestion that i would add along to this is creating a SysHelper class for this, in case you find this recurring. You can just pass the record or datasource and the method will disable all the fields.
public class SysDictTable extends DictTable implements SysDictXmlReflectionProvider, SysDictXmlDocumentationProvider { public static void disableDSfields(FormDataSource _fds) { SysDictTable dictTable; int i; ; dictTable = new SysDictTable(_fds.table()); for (i = 1; i <= dictTable.fieldCntWithoutSys(); i++) { _fds.object(dictTable.fieldCnt2Id(i)).allowEdit(false); } } }
Creating Edit methods for DS that don’t allow editing in Dynamics ax
Let’s say we have a Datasource and it is being displayed in the grid. The user has to choose one of it to further proceed. The use case is that you must be able to use a checkbox to select the records but you should not be able to modify rest of the information.
Technical implementation:
First Thought: Set allow create, allow delete allow edit property on the ds as false. Consequence: when you set allow edit as false you will no more be able to edit the checkbox also which is undesired.
Second Thought: Set allowedit false control wise either in the ds or in the formcontrol. Consequence: Too much work/customization. If done at formcontrol level the user can even add a field through
the syssteupform and start editing it (Refer here for details: http://wp.me/p298V-2IL)
Best Approach: Set allow edit to true in the ds 🙂 . Override the write method in the ds and comment the super. Consequence: Peaceful solution 😉
public void write() { ; I4C_InventTrans_ds.reread(); I4C_InventTrans_ds.refresh(); //super(); }
[tweetmeme source=”casperkamal” http://www.url.com only_single=false]
set field control at the lowest possible level in Dynamics Ax
When customizations are done with request to disable fields from editing the preferred approach for early developers is to just set it on the form control. But setting the allow edit “false” at the control level can have serious consequences. Watch the below video that shows you how easy it is to override this setting.
The ideal approach is to find the deeper level either in the form datasource or do it at the table level. This best practice would help retain the integrity of the application.
[tweetmeme source=”casperkamal” http://www.url.com only_single=false]
Renaming a Primary key like ItemId in Dynamics Ax
Whenever I go for a customer demo i try to align my data with their portfolio. It can be tedious if we try to create the entire data again. What i do is I smartly rename all the existing items instead of recreating the data. Ax has a handy option that lets you do this easily. Through this option you can even rename primary key’s not just item Id. Watch the video below to understand more.
Guess you will find it useful tooooo…..:)
Access the query of a formDatasource in Dynamics Ax
We all know well that to access the datasource in a form we use table name suffixed by DS. But there is one another similar suffix that can help us access the datasource query. See example below to understand.
Eg:
//note the suffix "_q"used to access the query. InventTable_q.datasourcetable(tablenum(InventTable)).addRange(fieldnum...
This is not widely used but can be of help at times.
Adding “Go to main table” for a display field in Dynamics Ax
Refer to the article below for a good article that displays how you can add the go to main table option for unbounded fields in Ax
http://www.fatihdemirci.net/index.php/2010/03/26/adding-a-go-to-the-main-table-form-link/
Article about refreshing data in form.
I have always seen people having confusion when it comes refreshing the data in a form. Here is a nice article from Kashperuk that can help you get clarity in this ….
http://kashperuk.blogspot.com/2010/03/tutorial-reread-refresh-research.html
Setting up Form size during runtime in Dynamics Ax
Sometime we change or construct a form at runtime. In those situation we end up modifying/setting the width and height at run time itself.
there is one thing you need to keep in mind if you are doing that.
Don’t use the following way to set the size of the controls in forms
tabcontrol.width(FormWidth::ColumnWidth);
tabcontrol.height(FormHeight::ColumnHeight);
tabcontrol.width(100);
tabcontrol.height(200);
then nothing happens for the Form. The form size is actually set to zero.
Instead you must do it the following way….
For Auto/ColumnWidth, height properties, set it like this
tabcontrol.widthMode(FormWidth::ColumnWidth);
tabcontrol.heightMode(FormHeight::ColumnHeight);
For setting manual values set it like this
tabcontrol.widthValue(100)
tabcontrol.heightValue(200);
I’m not sure for what reason it is done like this 😦