Some issues during changing index uniqueness

Some times we need to create a new unique index or alter existing one, but table may already contain duplicate data for this index and our changes could not be

How to get original value for table fields during record modification

Use table method orig(). It returns the orig buffer which is the committed version of the record in the database.

How dynamically change data source field properties

Example: myTable_ds.object( fieldNum( myTable, myField ) ).visible( false );

How to use select statements instead of query in data source

Override FormDataSource method executeQuery: public void executeQuery() { SomeTable T = this.cursor(); select * from T where …; } But be aware that in this case grid will not support

How to set focus when first time opening form

Override method firstField on a form, and call after super method setFocus of a control which should focused after form is opened. Example: public void firstField(int _flags=1) { ; super(_flags);

How to create EDT from code

It is impossible to create EDT from X++ using standard AOTAdd. AOTCompile causes Axapta crash and than unstable work. AOTSave method virtually doesn’t save anything. Solution: Use export/import methods. Steps:

How to check if AOT object name is valid

TreeNode::isValidObjectName( ‘Object name’ );

Search in AOT

Searching in AOT groups like Classes, Forms, etc. by scanning tree nodes is unacceptable due to performance reasons. For searching in AOT groups you should scan system table UtilElements. See

How to make data from temporary table available in form’s grid

Code in form’s outer scope: TmpTable tmpTable; FormRun formRun; ; … // Fill tmpTable with data here … args.record( tmpTable ); formRun = classFactory.formRunClass( args ); formRun.init(); formRun.run(); formRun.detach(); formRun.wait();

How to convert label to a string

edit LabelString helpTextValue( boolean _set, LabelString _value ) { LabelString ret; Label label; xInfo inf; ; if( _set ) { CDT_MenuItemList.HelpText = _value; } if( isHelpTextControlActive ) ret = CDT_MenuItemList.HelpText;