Cheque customizations in Dynamics AX 2012 – SSRS, expressions in SSRS reports

Friends,

Today , let us learn how to customize cheque formats in AX 2012. As you know that all MorphX reports has been moved to SSRS, it is essential to know how to customize the SSRS reports to meet the customer requirements.

I am going to customize Cheque_US format as an example. [I hope you all know how to generate payments AR/AP >> Journals >> Payment Journals >> Lines >> Functions >> Generate payments]

Below is the sample Cheque which I am trying to customize. I just want to replace US Dollars string to Dollars and deploy back.

Cheque

Now, Go to AOT\Visual Studio Projects\Dynamics AX Model Projects\Check_US_Report

Right click and chose Edit as shown below

Edit

It opens up the report in visual studio as shown below

visual studio

Expand the designs node >> report >> and select option “Edit using Designer” as shown below

 

Edit using designer

In the design mode, Select the control CurrenyTxt >> right click and chose PlaceHolder properties as shown below

Place holder properties

In the Properties form >> select the expressions button as shown below

Expressions button

In the Category >> Common functions >> select Text and you will find the list of functions which we can use on string controls.Select replace option as I am going to find the string “US Dollar” and replace it with “Dollar”. I have highlighted how to use the replace expression in the below screen shot.

replace

Use the replace expression/function as show below and click on Ok Button. Click again on Ok button on the previously opened

placeholder properties form.

 replace function

We are almost done, next thing is to save the changes to AOT. Go to Solution explorer,Select Cheque_USReport >> right click >>

Add Cheque_USReport to AOT as shown below.

save to AOT

You should get the successful message in the output window that the changes has been updated to AOT as shown below.

deployed to aot

Close the Visual studio, Open AX Client, Ctrl + D , Go to AOT >> SSRS Reports >> Reports >> Cheque_US. You should see that the object has been modified in the usr layer.

 

checccck

Now, right click on the Cheque_US report and chose Deploy element as shown below

deploy element

You should get a successful info log of the report deployment as shown below.

success

Now generate the payments and see the end result. you will find that “US Dollar” has been replaced with “Dollar”. This is just a sample example to show how to use expressions and customize the standard Cheque’s. Do not look in to functional aspects. 🙂

us dollar replaced

That’s all for now.

Happy Dax6ng,

Sreenath

Advertisements

Cumulative Update 2 [CU2] for Microsoft Dynamics AX 2012

Friends,

Microsoft Dynamics AX 2012 – CU2 has been released. You can download the same from the following link

http://support.microsoft.com/kb/2606916

Information:

Cumulative Update 2 contains hotfixes for Microsoft Dynamics AX 2012 that were fixed since the release of Microsoft Dynamics AX 2012. This article contains information about how to obtain the cumulative update and about the issues that are fixed by the cumulative update.
Note The build number of this cumulative update package is 6.0.947.280

Thanks,

Sreenath Reddy

Release products to the legal entities using X++ [Dynamics AX 2012]

Friends,

In this post, I would like to share X++ Code that will help to release products to the legal entities from product master.

In Microsoft Dynamics AX 2012, Microsoft has enhanced the item-product data management framework to provide flexibility and sustainability across the organization.In Microsoft Dynamics AX 2012, all product master data is shared across all companies, and the virtual table collection concept is no longer available for product master data management. The old item representation (InventTable) still exists[msdn]

I will be using 2 legal entities – CEU and newly created legal entity ‘RAX’
[If you want to create new legal entity – Organization administration >> setup >> Organization >> Legal entities >> New]

Let me show you the product master data [a particular product] which I am trying to release using code.

EcoResProductReleaseManagerBase class will help to release products to the legal entities. static method -releaseproduct will release products.

static void SR_ReleaseProducts(Args _args)
{
EcoResProduct ecoResProduct;
;

select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == “20003”; //Audio system
EcoResProductReleaseManagerBase::releaseProduct(ecoResProduct.RecId,
CompanyInfo::findDataArea(‘RAX’).RecId);
}

After running the above job, you will see that 20003 product number has been released to legal entity ‘RAX’ as shown below.

I know most of us are very familiar of creating items using code in AX 2009. Now, let me walk through with the equavalent code in AX 2012 [Hope I got it right, please note: This code is an attempt to findout the way it is in AX 2012. Request to test the code in dev environments before using them in live]

static void SR_ReleaseProducts_detailed(Args _args)
{
EcoResProduct ecoResProduct;
InventTable inventTable;
InventTableModule inventTableModule;
NumberSequenceTable numberSequenceTable;
ItemId itemId;
InventItemSetupSupplyType inventItemSetupSupplyType;

EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
;

select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == “20003”; //Audio system

changecompany (‘RAX’)
{
ttsBegin;
inventTable = null;
inventTableModule = null;
inventItemSetupSupplyType = null;
ecoResStorageDimensionGroupProduct = null;
ecoResTrackingDimensionGroupProduct = null;
ecoResStorageDimensionGroupItem = null;
ecoResTrackingDimensionGroupItem = null;

numberSequenceTable = InventParameters::numRefItemId().numberSequenceTable();
//get item id from:
//1. Product number if number seq for item ID is not set up or manual or return blank value
if (!numberSequenceTable.RecId || numberSequenceTable.Manual)
{
itemId = ecoResProduct.productNumber();
}
else //number sequence auto, get a number
{
itemId = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
}

inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = ItemId;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);

// Create inventTableModules

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();

//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);

// Creates a new item default order type for the product that is released.

inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();

//create relationship tables to dimension groups.

ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProduct.RecId);
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProduct.RecId);

if (ecoResStorageDimensionGroupProduct.RecId)
{ // mandatory storage dimension group for the product
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}

if (ecoResTrackingDimensionGroupProduct.RecId)
{ // mandatory tracking dimension group for the product
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
ttsCommit;
info(strfmt(“Product successfully released to ‘RAX’ legal entity”));
}
}

In Microsoft Dynamics AX 2012 inventory dimensions have been divided into the following three categories:
Product dimensions:These correspond to the old item dimensions.
Storage dimensions:These are Site, Warehouse, Location, and Pallet.
Tracking dimensions:These are Batch number and Serial number.

Happy Dax6ng,
Sreenath

Segmented Entry Control on Forms in Dynamics AX 2012 [Ledger Dimension/Ledger account lookup X++]

Friends,

I was going through the segmented entry control on the form and found that AX 2012 has changed the way ledger dimensions populate on the form.

A new control type has been added in AX 2012 as shown below.

You can add a segmented entry control to a form when you want that form to show an account number and related dimensions from the chart of accounts. In addition, you use the segmented entry control to associate an account and related financial dimensions with the record that appears in the form. To update the values in the control, you can use a lookup or a list of recently used values to select a value for each segment. Finally, you can have the control validate the updated segments to ensure the account and financial dimensions are a valid combination[msdn]

For more information : click here

Let me show you how to quickly get this working on the form.

To explain this, I am using ProjParameters Table.
Add a new Int64 field to ProjParameters Table by name “LedgerDimension”
and set the extendedDataType as “LedgerDimensionAccount”

Add a new relation with “DimensionAttributeValueCombination” table.Right click on the relations Node >> New relation and set the relations as shown below

Now create a normal relation as shown below. Right click on the newly created relations and chose Normal relation.


we are done with the table customization and lets move to the form “ProjParameters”

Go to AOT >> Forms >> ProjParameters >> right click on the form and restore.

Expand the datasources node >> projParameters >> Drag and drop the LedgerDimension field on to Design >> General TabPage as shown below.

Once you drag drop this datafield ledgerDimension, a new segmentedEntry control will be created. Save the form and open the form [Ctrl + O].

you will find the ledger account control in the General Tab. But when you try to look at the ledger accounts, you will not find anything[empty – no lookup values]..

hmm.. interesting..what am I missing here?? Let me help you how to get this..

In AX 2012, there is a class “LedgerDimensionAccountController” which does the trick of population of accounts. LedgerDimensionAccountController class provides control interaction logic for any use of the account number control in the UI.

Lets proceed. Go to the classdeclaration and create an object for LedgerDimensionAccountController class as shown below

public class FormRun extends ObjectRun
{
//..standard code
LedgerDimensionAccountController ledgerDimensionAccountController;
}

Override the init() method of the form and instantiate the object of the class as shown below with the projparameters_ds and the field name “LedgerDimension”

public void init()
{
//…standard code
// Initialize account controllers
ledgerDimensionAccountController = LedgerDimensionAccountController::construct(projParameters_DS, fieldstr(ProjParameters, LedgerDimension));
}

Go to datasources >> projParameters >> fields >> ledgerDimension >> add a new method called resolvereference as shown below

public Common resolveReference(FormReferenceControl _formReferenceControl)
{
return ledgerDimensionAccountController.resolveReference();
}

After you add the control to the form, you must provide the control with the ability to retrieve data, select a value for a segment, and validate the selected values. Typically, you use a controller class to override several segmented entry control methods.

Now, expand Design node >> segmented Entry control which has been recently created >> right click and override the “jumpref” method and add the below code

public void jumpRef()
{
ledgerDimensionAccountController.jumpRef();

super();
}
Right click again on th segmented entry control and override “loadAutoCompleteData” method and add the below code

Public void loadAutoCompleteData(loadAutoCompleteDataEventArgs _e)
{
super(_e);

ledgerDimensionAccountController.loadAutoCompleteData(_e);
}

Right click again on the segmented control and override “loadsegments” method and add the below code

public void loadSegments()
{
super();

ledgerDimensionAccountController.parmControl(this);
ledgerDimensionAccountController.loadSegments();
}

Right click on the segmented entry control and override “segmentValueChanged” and add the below code

public void segmentValueChanged(SegmentValueChangedEventArgs _e)
{
super(_e);

ledgerDimensionAccountController.segmentValueChanged(_e);
}
Lastly , right click on the segmented control and override “validate” method and add the code below

public boolean validate()
{
boolean isValid;

isValid = super();
isValid = ledgerDimensionAccountController.validate() && isValid;

return isValid;
}
For more details on the overridden methods above : click here

Done, we are good now to see the ledger accounts with the segments [if any] in the lookup.

Right click on the projParameters form and open the form.


Thats it for now….Good day..
Sreenath Reddy