The idea is to build a comprehensive list of tips that could be used to handle day to day scenarios
A. Get a lookup field to show up on a form
- For the lookup button to appear for a field on the form the property LookupButton should be set to Auto and there must be a relation setup on the form for this field in the data source.
- Another way to create a lookup is to override the control’s lookup method and basically create the lookup list yourself. However the fields that are displayed in the lookup form can either come from the data source’s fields, display methods.
- For the ViewDetails functionality to work, either the form name has to be the same as the table name or the property FormRef (on the table) has to be set to the correct form.
B. Want to identify which field was modified in a form. This could be used by an outbound interface to selectively send out the fields that have been modified.
- Override the modifiedField(FieldId _fieldId) method to get to the field that was modified on a table.
- You can get to the previous/old value of the field by using this.orig().(_fieldId). this.orig() gives access to the old record buffer.
- There is another method called modifiedFieldValue and one of the things to watch out for is that although both modifiedField and modifiedFieldValue can be used, however modifiedField seems to work in CIL but not modifiedFieldValue (Ref: http://www.van-veldhuizen.eu/blog/2012/06/08/microsoft-dynamics-ax-2012-difference-between-modifiedfield-and-modifiedfieldvalue-methods/). Haven’t had a chance to verify this
- Since this method is on the table, to access the form when this table is used as a datasource, you can use element keyword. ex element.MyMethod(). Where the method MyMethod() is actually declared on the form.
- Also remember to set the AutoDeclaration property of any new control you create, this allows the use of the field name without having to declare it.