Friday, September 19, 2014

Active project contracts in Microsoft Dynamics AX 2012 R3

Hi Friends,
In Microsoft Dynamics AX, project contracts are created to setup the funding sources, define funding limits on the funding sources, maintain uniform invoicing procedures and also for invoicing one or multiple projects at a same time. These can be found at Project management and accounting > Common > Projects > Project contracts.


In AX2012 R3, on the project contracts list page, you will find filter to show the contracts which are "Active". This filter is not available in previous versions of AX and caught my attention when I opened this list page in R3 environment.



Eager to know what is an active project contract, I jumped into the technical artefacts of this list page and found that active project contracts are those which are defined on a project whose status is not completed. So after creating a project contract we do not need to set it as active. There is no field in project contracts table which stores this value. It is considered active as soon as it is defined on any 'not completed' project. 

Note: This filter is not available on EP. It is only shown on the AX client.

The way standard AX does this filtering is interesting and different from the traditional way of creating such filters. This prompted me to write the post :).

1. The display target property of the filter group is defined as client. As a result, this feature is only available on AX client. Also, we can override method on the controls inside this group. 



2. If the value on the 'show contract' control is selected as "Active", then the datasource "ProjTable" of the query object is enabled. 


3. Nothing special till now. Let's look at the query used on the list page. Note that the "ProjTable" is not defined as a datasource on this query.

4. So now things become interesting! When is the data source "ProjTable" added in the query? To find this, let's check out the interaction class used in the list page. Interaction class name can be checked from the property of the list page: 


Look at the initializeQuery() method of the interaction class, you will find the below piece of code which is doing the little magic and making the whole thing interesting to share: 

















  1. "ProjTable" data-source is added in the query as a datasource.
  2. Using sysDictRelation classes, the relation is defined between data-sources of projTable &  ProjInvoiceTable.
  3. The join mode is set as "Exists Join". 
  4. The range is defined on ProjTable status field as "Not Completed".  Note the queryNotValue function used in defining the range.
  5. The data-source is enabled/disabled on the 'show contract' filter control value.
The above code is a good example to understand how we can add relations and use exists join in query data sources. This approach is also helpful if we need to do a similar customization.

To read more about project contracts refer to the technet link Project contracts

Thanks for reading the blog. 

2 comments:

  1. Thanks for sharing, nice post! Post really provice useful information!

    An Thái Sơn với website anthaison.vn chuyên sản phẩm máy đưa võng hay máy đưa võng tự động tốt cho bé là địa chỉ bán máy đưa võng giá rẻ tại TP.HCM và giúp bạn tìm máy đưa võng loại nào tốt hiện nay.

    ReplyDelete