Search This Blog

Saturday 21 December 2013

Change Company Design Pattern In Microsoft Dynamics AX 2012


By the help of change company design pattern we can change the company context with in a particular scope.

For example there is a scenario in which we have to get the data based on the company context which is not our loggedin company in that case we can use this change company design pattern to change the company context in a particular scope.

You can see the examples in the below links.

Change Company Design Pattern [AX 2012]

Cross-Company Data Modification Using X++ [AX 2012]

Above links for changing the company context were for the particular scope but if you want to change the company context inside the entire form than you can call the below method.

appl.setDefaultCompany(selectedLegalEntityDataAreaId, false);

Note:The main Drawback in above method is that when you switch over from the form on which company context is change than you will got the infolog that company change from this to this.

You can see the detail of that method in the below link:

Application.setDefaultCompany Method [AX 2012]


You can see the existing example of that method.

Just go to the Human Resouce ->Periodic ->Budget Planning -> Forecast Positions

Forecast Position List page will open just double click any forecast position and than click edit button
Forecast Position will open in edit mode.

Now go to the Compensation Group tab of that  form and right click the lookup and click view detail as you can see this in the below image.











Now after clicking on the view detail button you can see the form is open.

This new form will open in the context of the company assigned on the forecast position not based on the logged in LE.And will show compensation groups created in that LE only as you can see this in the below image.












Now on the jumpref method of the form HcmPositionForecast I have right this code.As you can see this in the below image.





















This was all related to the change company design pattern.

I hope you like this post.I you have any questions related to that than you comment or feel free to approach me.

Thanks

Muhammad Zahid.

No comments:

Post a Comment