Consuming Pending Vendor invoice service from C#

This blog refers to consuming or creating Pending vendor invoice record in dynamics ax 2012 R3 using out of box service “VendVendInvoiceService”. The focus of this blog is .net C# side. In this example I took the complex case of creating Vendor invoice that linked to multiple PURCHASE ORDERS in received status.

This ADDHeader method insert record in VendInvoiceInfoTable, for this example I just filled the required ones.


This ADDLine method insert a line in VendInvoiceInfoLine table. this is helper method will be called from main executing point.


This is the main executing method, In this method I did initialization of required objects, make find call of two purchase order records using Purchase order service (You could do this by any way, hard coded or service call or through .net proxies). Here I am also making the call of AddHeader method to create the header record


Further on the same method, call AddLine to create Line record, Also specify the QTY that how much I want to invoice from the receiving, I did the same for both the purchase orders.


After composing complete message, making Create call to service


Amir (Happy Daxing)


Settlements (Technical Utility methods)

Piece of code that checks if the invoice is already marked with some payment or not

 protected boolean checkIfAlreadyMark(CustVendTransOpen _custVendTransOpen)  
   specTransManager specTransManager = specTransManager::construct(_custVendTransOpen);  
   return specTransManager.existForOtherSpec(, _custVendTransOpen.TableId, _custVendTransOpen.RecId);  

Piece of code that settles the invoice with the payment

 protected void markSettlement(CustVendTransOpen _custVendTransOpen)  
   CustVendOpenTransManager manager = CustVendOpenTransManager::construct(ledgerJournalTrans);  
   manager.updateTransMarked(_custVendTransOpen, true);  

Opening Balance import through DIEF (Data Import Export Framework

Hi Guys and Happy Independence day to all my country mates and Happy Birth day to PAKISTAN


Okie, This exercise is about importing Opening Balance through DIEF (Data Import Export Framework, I am using Dynamics AX R3 CU8.

1 Create “Processing Group” – “Opening Balance”


2 Click Entities and select Entity as “Opening Balance”
3 Select Source data format as “Excel”
We need to create source data format record as this6

4 Click Generate Source file for generating the template, We can select all the needed fields here.


5 Click Modify Source Mapping,
Ops here I got the error

Error Message: Assembly containing type Microsoft.Dynamics.AX.Framework.Tools.DMF.ServiceProxy.DmfEntityProxy is not referenced.

Object ‘CLRObject’ could not be created

There can be multiple reason for this issue but I solved it through these steps.

Solution: Above mention error come because you are trying to set parameter without installing its component (Service, Server and Client). Just install those component from setup file and restart the AOS service. Now this error should not bother you this time. :)

After restarting the AX, I have open the parameter form, specified the correct shared working directory and validate the settings.



5 Click again on “Modify Source Mapping,”

As we need Journal Number to be Auto generated, I modify it by marking JournalNumber auto generated, and I also added the JournalName field in Query Criteria such that all the lines (with the same JournalName value) will be assigned the same JournalNumber


After this select the excel file with data in the ENTITIES form and click preview to viewing the data.


In the last for moving the data to staging table, click “Get staging data” then for copying the data to target, click on Copy data to target.


and here we have the end result



Get default financial dimension values through X++ code

This topic is not new and we have lots of blogs available on it. Yasir Co-blogger also explained this quite well in his blog. The purpose to share this again here that I have did some minor modifications in his job to get both attributes (Value and Name) for Default dimension. Complete code is here.

static void GetDefaultDimensionAttributeName(Args _args)
    DimensionAttributeValueSetStorage    dimStorage;
    HcmPositionDefaultDimension          HcmPositionDefaultDimension;
    DimensionAttribute  DimensionAttribute;
    Counter                                               i;
    DimensionAttribute          dimAttr;
    DimensionAttributeValue     dimAttrValue;
    Common                      common;
    DictTable                   dictTable;
    str                         Name;
    str                         value;

    // get the dimension value from position    
    HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(HcmPosition::findByPosition("000001").RecId,CompanyInfo::find().RecId);

    // make the dimension storage object    
    dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
        // get attribute select here.
        select firstonly dimAttrValue
        where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
        join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

        if (dimAttr && dimAttrValue)
            dictTable = new DictTable(dimAttr.BackingEntityType);
            common = dictTable.makeRecord();

            if (common.TableId)
                select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                name = common.(dimAttr.NameAttribute);
                value = common.(dimAttr.ValueAttribute);
        info(dimAttr.Name +"----" +value + "----"+name);

output image

we can check the other examples on same topic from Yasir’s Blog – Microsoft Dynamics AX


Get every new post delivered to your Inbox.

Join 534 other followers

%d bloggers like this: