AX 2012: Create a project from a specific layer

To create a project to include all the existing objects from a specific layer, perform the following steps:

1. Press Ctrl+Shift+P to open the Projects window
2. Right click the Private/Shared project node to create a new project
3. Open the newly created project in a new window
4. Click on the Advanced Filter/Sort button to open the Project Filter window
5. From Groupings check AOT to group objects like they are grouped in AOT
6. Click on the Select button to open Inquiry window
7. In the Range grid, select usr for the SysModelLayer record
8. Click OK button

 

Untitled

Advertisements

AX 2012: Add dynalink in X++

Use the following code to add dynalink to the form datasource query:

public void init()
{
    super();
    
    this.query().dataSourceTable(tableNum(MzkPurchTrackingDetailsTable)).clearDynalinks();
    this.query().dataSourceTable(tableNum(MzkPurchTrackingDetailsTable)).addDynalink(
        fieldNum(MzkPurchTrackingDetailsTable, PurchId),
        PurchParmTable,
        fieldNum(PurchParmTable, PurchId));
}

Where,

  • First parameter is the source table field
  • Second parameter is the destination table
  • Third parameter is the destination table field

AX 2012: Refresh caller form datasource

The following code refreshes the caller form datasource from the calling form:

void clicked()
{
    Args    arg = new Args();
    FormRun formRun;    
    ;

    arg = new args(formstr(YourForm));
    arg.record(yourTable);
    arg.caller(this);
    formRun = classFactory.formRunClass(arg);
    formRun.init();
    formRun.run();
    formRun.wait();
    formRun.detach();
    
    YourTable_DS.reread();
    YourTable_DS.rereadReferenceDataSources();
    YourTable_DS.research(true);
}

1. reread() – Rereads the current record from the database
2. rereadReferenceDataSources() – Rereads the reference records of the current record from the database
3. research(true) – true parameter retains the current position of the dataSource cursor after researching

AX 2012: Add financial dimension for your table

Lets quickly take a look at how the financial dimensions framework has been redesigned in AX 2012. The following picture show the table design:

Untitled

To add a new financial dimension for your custom table, perform the following steps:

1. Drag the EDT (AOT >> Data Dictionary >> Extended Data Types >> DimensionDefault) to the fields of your table
2. Create a new “Normal” relation on your table linking the newly added “DefaultDimension” field to the “RecId” field of DimensionAttributeValueSet table

Untitled

3. Now create a view for your table. Take care of the following conventions:

  • View should be named exactly DimAttributeYourTable
  • Add your table to DimAttributeYourTable >> Metadata >> Data Sources node
  • This data source should be named exactly BackingEntity
  • Add the following three fields naming them exactly as mentioned
    • Key – Use surrogate key field e.g. RecId
    • Value – Use natural key field e.g TrackingNum
    • Name – Use any descriptive field e.g. DeliveryName

Untitled

4. Create and run the following  job to clear the dimension cache:

static void clearCache(Args _args)
{
    DimensionCache::clearAllScopes();
    info("done");
}

5. Now open General Ledger >> Setup >> Financial dimensions >> Financial dimensions
6. Create a new financial dimension
7. Select your newly added dimension from the “Use values from” lookup:

Untitled


Now if you want to add this financial dimension to any of the existing chart of accounts, perform the following steps:

1. Open General Ledger >> Setup >> Chart of accounts >> Configure account structures
2. Select any of the active account structures e.g. “Account Structure P&L (Active)”
3. Click Edit button
4. Click Add segment button
5. Select the newly added dimension
6. Finally activate the dimension to let the changes take effect.

Untitled

AX 2012: How to open a form in X++

Using FormRun:

void clicked()
{
    Args    args;
    FormRun formRun;
	
    args = new Args(formstr(CustTable));
    args.record(custTableLocal);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
    formRun.detach();
    CustTable_DS.research();
}

Using MenuFunction:

void clicked()
{
    Args args;
	
    args = new Args();
    args.caller(this);
    args.parmObject(list);
    new MenuFunction(menuItemDisplayStr(SalesTable), MenuItemType::Display).run(args);
}