Useful functions to use in AX 2012 part 2
The workflow process moves purchase requisitions through the review process, from an initial status of Draft to a final status of Approved. When a purchase requisition is submitted for review, the workflow process is started. After a purchase requisition is approved, a purchase order can be generated for the purchase requisition lines and submitted to the vendor for order fulfillment.
We will use AIF standard service for import PR from outside, service name
AxPurchReqTable class and
Base on this method, you could know how System get PurchReqId.
How to do
Go to Inbound ports form to create new service with
NETTCP adapter, choose service operations likes below:
active AIF inbound service
Consume Pruchase requisition service
Open visual studio and create new console project.
Add service reference
This one just for demo, so I just create code base on required fields of AIF.
Here is the code in
Run it and check result in AX
Please prefer previous post for another operations
Thank you for reading!
In previous post, I already show how to create purchase order through AIF with
HTTP adapter. In this post, we will get little deep more about action on line of order.
The following code sample shows how to
delete a line of an existing purchase order through AIF, currently I’m using C#.NET console project for demo.
As Partial update, we must include just the fields to change and any fields required by the document (you can check
Data policies in AIF Service ports form for that).
Also, notice how action properties are specified – no matter we do with the line, which means updating the order.
I’m giving you an idea how it looks like, here is the code
The first method will handle the key of AIF Service
create Line, delete Line, update line in Purchase order
Thank you for reading!
Due to Purchase order doesn’t have Standard document service so we have to create new Document service for that using AIF wizards.
I’m using AIF document service with
HTTP Adapter to Create Purchase order service, here is steps
with three datasouce (
PurchTable, PurchLine, InventDim) likes below
As best practice for Document service, name of query should be start with Axd* prefix.
Using AIF Wizards
In AX development environment, go to Tools > Wizards > AIF document service wizards
Choose recent created query and click next.
Create Service operation and
next and then
You will get service project in Private project
Deploy and create service
• Right click on
PurchOrderService > Add-Ins > Register service
• System administration > Setup > Services and AIF > Inbound ports
Inbound ports form and name the Service.
• Adapter: NETTCP (it also works with HTTP adapter)
• In Service contract customizations fast tab click
Active recent created Service
Consume service using C#.NET
After service is activated, you can get WSDL URI likes
Create console project and Add Service References, the code below
In Class, I will write method to return list of
Code for create purchase order
Code for read purchase order
Code for update purchase order
Code for delete purchase order
Thank you for reading!
I’m trying to create product/master product in Dynamics AX using AIF inbound port, the AIF services consume by C#.NET.
From AX 2012 R2, Item is replaced with Product. Item master was in Inventory Management Module, now there is a separate module for item/product creation
Product information Management.
Some definitions you should know There are two types of Products in 2012 they are:
Product information management/Common/Products/Products
Product information management/Common/Products/Products master
To create a product variant, you must define at least one product dimension for a product master. You can also rename dimensions. To create product variants, you must complete the following tasks:
Set up dimensions, such as size, color, and style.
Set up variant groups.
Assign variant groups to a retail hierarchy.
Create a product master and variants.
b. Product dimensions
Product dimensions are characteristics that serve to identify a product variant. You can use combinations of product dimensions to define product variants. You must define at least one product dimension for a product master to create a product variant.
Normally in AX, we create items master follow process:
Create product/product master.
Assigning Dimensions Groups to a Product Master.
Create Product dimension combinations (Product Variants)
Release product to legal entities
Assigning Item Model Group & Item Groups to a Product Master
How to do:
Ax provides us standard services for this purpose, so we don’t need to create any custom services for this. I will use 4 services for this purpose, descriptions below
||Create products (all types). The service can also be used to retrieve data that has already been created (Create Product details in The EcoRes tables).|
||Specify values of product dimensions for a product master. These values become available for the creation of product variants. The service can also be used to retrieve data that has already been created.|
||Release distinct products and product masters. The service can also be used to retrieve data that has already been created.|
||Release product variants. The service can also be used to retrieve data that has already been created.|
we have 4 steps
Create 4 AIF inbound services against Services operation above and active it
After services creation, open visual studio then creates new Console project and add service References for that, you will get somethings like pic below:
Using C#.Net to consume service
this method can use to release a distinct product or a product master
Release product Variants
Just for example, in
main I only create Distinct product and release it, but you can use another method to create master, variant, masterDim and so on.
4. Try to run it and here is a result
Thank you for reading and feel free to give me a question.