Dynamics AX
  RSS Feed  LinkedIn  Twitter
Want to turn you're data into a true asset? Ready to break free from the report factory?
Ready to gain true insights that are action focused for truly data informed decisions?
Want to do all of this across mutliple companies, instances of Dynamics and your other investments?
Hillstar Business Intelligence is the answer then! (www.HillstarBI.com)

Hillstar Business Intelligence for Microsoft Dynamics AX and NAV on Mobile, Desktop, Tablet


Let us prove to you how we can take the complexity out of the schema and truly enable users to answer the needed questions to run your business! Visit Hillstar Business Solutions at: www.HillstarBI.com

Tuesday, August 30, 2011

Microsoft Dynamics AX 2012 - A Dive into Services, Consuming Document Services



With the release of Microsoft Dynamics AX 2012, one of the topics I have been spending a lot of time talking about is around services. There is good reason for this, and we will continue to dive deeper and deeper into the concepts, the reasons for use, and examples of use.

Last I left off, we covered topics related to Custom Services. In this post, I want to take and cover concepts around the consumption of document services.

As I referenced in a previous blog post, there is a great write up already, that covers the technical steps needed to show off how to consume document services, specifically around the Product Data, or the EcoResProductService.

This write up, found here: Product-item data management services, focuses on the consumption of the EcoResProductService, among others, for creating product data, and even releasing that into a given legal entity. Since this is a very nice write up, I will not focus this post on repeating the same effort.

Instead, what I want to focus on, is consuming the EcoResProductService, from within X++, from within AX, for creating Product Master Data. So lets jump right into this.

First thing that we need is an instance of AX 2012, and a project. We will then need, within that project, a custom service group to deploy the out-of-the-box EcoResProductService via. After that, we will need a class, to contain the business logic, and finally for our example a job that kicks off that classes method, and therefore logic for creating our Product Master.



As you can see, from the above image, we have just that for our example. Now since there is nothing we need to really do to the EcoResProductService, lets move into the business logic for creating a Product Master record.

First we need to start with the variables that will be involved in, enabling this.:



You will notice, we have an EcoResProductService variable, which is used to perform the operations that are enabled for a given service, in this case document service, and for our need the create() function.

Next you will see we have a variable that presents the EcoResEcoResProduct object. This is what the EcoResProductService will accept in it's create call that we will see in a bit. This class extends from the AifDocument class, as you can see from the below image.



After that, we have EcoResEcoResProduct_Product_Master class, which is extends from the EcoResEcoResProduct_Product class, which further extends from the AfStronglyTypedDataContainer. You can see this as well, in the image below here.



From there we have variables that represent the EcoResEcoResProduct_Translation, EcoResEcoResProduct_Identifier & EcoResEcoResProduct_ProductDimGroup objects. All of which are used to help make up an EcoResEcoResProduct_Product_Master object.

Now all of that is a mouth full! The point is, we have, in order to work and create Product Master entries, via the Document Services concept, is six objects. These six objects in our example abstract the complexity of the new EcoResProduct data structure, and enable within AX for business logic to move away, from even working directly with the table objects within AX itself. This is very powerful, and very useful.

Now lets move forward, since we have an understanding of the objects that will enable us to create a Product Master record, and look into the code that enables this.



First part of the code, we see in the above image, our logic that initializes the service for use. Then we move towards creating a new instance of the EcoResEcoResProduct object. After that we are creating our Product Master object, and finally filling some of it's parameters, via the use of parameter methods, with values.



Next we are making use of the objects that make up our Product Master object, in the ProdMast variable, for creating the needed: Translation, Identifier and for our example the Product Dimension Group.

You will notice that the code to enable this is ProdMast.createTranslation().addNew(); In doing this, and for the other examples this is true as well, we are creating a new instance of the Translation object, and adding it to the AfStronglyTypeDataContainerList that is represented for the ProdMast variable.



Finally, we come to the bottom of the code block for this business logic, and see we are setting the Variant Configuration Technology. Then adding our ProdMast object to the Strongly Type List for the EcoResProd variable. Finally calling the create method of the service object, passing in our ProdMast variable.

On calling this logic, we get our Product Master record, as shown below.:


So with a total of 17 lines of code, and 6 objects, we are working with Document Services from within AX 2012 itself, and creating Product Master data, without having to work directly with the table objects themselves.

This can then lend itself to be re-used over and over again, and finds value in integration work, as well as data migration. You can also, now take and compare the differences between C# and X++ code for using these document services. They are similar, in theory, but different in syntax and possible approach of course.

That's all I wanted to cover for this series, and for the introduction to services in AX 2012 this just about wraps things up. I plan on doing a summary post, bringing together all the work I've done, all the work Microsoft has done, as well as other community contributors. Till next time!



"Visit the Dynamics AX Community Page today!"


Labels: , , , , , , , , , , ,

2 Comments:

Blogger Mohammed Arif Hussain said...

Hi Brandon

Could you please share with me the steps on above example.

Thanks

Arif

8:43 AM  
Blogger Mohammed Arif Hussain said...

Hi Brandon

The Article nice one i appreciate please keep doing sharing good work with us.

Could please share with me steps to achieve above example.

my email id arif_tec@hotmail.com

Thanks

Arif

8:48 AM  

Post a Comment

Links to this post:

Create a Link

<< Home


Copyright 2005-2011, J. Brandon George - All rights Reserved