Friday, 8 June 2012

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:
  1. Find any EDT node using AOT methods.
  2. Use SysTreeNode::CopyNode() to copy node to the new EDT node.
  3. Change properties according to the needs for the new node.
  4. Export new node EDT to temporary folder.
  5. Parse exported file and set USERTYPE property the same as NAME property.
  6. Import changed xpo file.

Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian  

How to copy dynamic links from one query to another


See example below:
public void init()
{
    Query query = new Query(queryStr(myQuery));
    super();
    SysQuery::copyDynalinks(query, this.query());
    this.query(query);
}

Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian  

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;
    else
    {
        inf = new xInfo();
        if( inf )
        {
            label = new Label( inf.language() );
            if( label ) ret = label.extractString( CDT_MenuItemList.HelpText );
        }
    }

    return ret;
}



Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian  

How to check if your variable suit the conditions given in query range


Use inRange methods from Global class
static boolean inRange(str _rangeValue, anytype _value)
Example:

{
    str   _rangeValue;
    str   _value ;
    boolean          result;
    ;
    _rangeValue  = ‘200..500’;
    _value          =  ‘300’;

    result  = Global::inRange (_rangeValue , _value);
}
The result variable will be equal to true


Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian  

How to check if AOT object name is valid


TreeNode::isValidObjectName( ‘Object name’ );


Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian  

How to access field in a table using this field id


To do this you could use next construction:
myTable.( filednum( myTable, myField ) ) = “XXX”;
This is the same as
myTable.myField = “XXX”;
Example:
Field AccountNum from CustTable have id 1. Then statement CustTable.(1) = “4000” – will initialize field AccountNum with value “4000”.
You could also use this feature while working with record of type Common.
Example:
    Common      common;
    CustTable    custTable;
    ;
    select custTable where custTable.AccountNum == "4000";
    common = custTable;
    info( common.( fieldnum( custTable, Name ) ) );
The output of running this code will be the info log with a message “Light and Design”, Where “Light and Design” – name of the customer with id “4000″.


Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian   

How dynamically change data source field properties


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


Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian