Access D365 FinOps Services with OAuth 2.0

So before we jump in how to, we need to understand some basics how OAuth2 works.

well basically OAuth2 is one of the authentication out there, the purpose is to is validate and authenticate with Azure AD, permission granted or not to access the apps. if granted, it will generate “TOKEN”.

now we heading to D365FinOps , in D365 FinOps we have users and all of its security roles, so basically user that can call D365FinOps services (example OData or Custom Services) via OAuth 2.0 should be only legitimate D365 FinOps users.

There is some grant_type for OAuth 2.0 that works with D365 FinOps :
1. Authorization Code : when user access or call some services, they need to provide login information . (works with D365 FinOps, just provide user and password when microsoft login window popup) , then TOKEN generated.
ref :

2. Password Credentials : the user and password credentials is hardcoded in the call, so no popup window login, then TOKEN generated afterward.
ref :

other grant_type seems not working wih D365 FinOps because cant provide legitimate D365 FinOps User in the call parameter.

Now let us try shall we ??
the summary for the tutorial (will update in next blog post) :

1. Setup Apps Registrations in Azure AD and Setup in D365 FinOps
2. Generate Oauth2 Token using grant_type Authorization Code
3. Generate Oauth2 Token using grant_type Password Credentials
4. Testing OAuth2 Token to call OData Services
5. Create Simple D365 FinOps custom services
6. Testing Oauth2 Token to call D365 FinOps custom services.



get filter value from grid

example code :

public void getQueryValue()
    QueryBuildRange range;
    int ct, i;

    ct = PMTRoutingTable_ds.queryRun().query().dataSourceTable(tablenum(PMTROutingTable)).rangeCount();

    for (i=1 ; i<=ct; i++)
        range = PMTRoutingTable_ds.queryRun().query().dataSourceTable(tablenum(PMTROutingTable)).range(i);
        info(strfmt('Range Field – %1, Value – %2',range.AOTname(),range.value()));

references :

error : “Target principal name is incorrect” when running SSRS AX 2012 R3

Example of the error :

In my case , the issue occurred because outdated *.AXC files (ax configuration files) in report server folder.  error cause is still unknown, my client not provided details on what changes they did in the ax server.

How to solve this issue :

  1. Create New AX Configuration Files, refresh WCF (using Refresh Configuration).


  1. Export it to a file and rename it to Microsoft.Dynamics.AX.ReportConfiguration


  1. then replace the file with new one in folder path C:\Program Files\Microsoft SQL Server\MSRS11.\Reporting Services\ReportServer\binCAPTURE1

Get purchase invoice id from packing slip trans (VendPackingSlipTrans)

static void ExampleJob(Args _args)
    VendPackingSlipTrans packingSlipTrans;
    VendInvoicePackingSlipQuantityMatch VendInvoicePackingSlipQuantityMatch;
    vendInvoicetrans vendInvoiceTrans;

    select firstOnly packingSlipTrans where packingSlipTrans.RecId == 5637155083;

    select firstonly vendInvoiceTrans
    join VendInvoicePackingSlipQuantityMatch
        where VendInvoiceTrans.SourceDocumentLine == VendInvoicePackingSlipQuantityMatch.InvoiceSourceDocumentLIne
            && VendInvoicePackingSlipQuantityMatch.PackingSlipSourceDocumentLine == packingSlipTrans.SourceDocumentLine;



credited to : EYO

Missing reference for “display method returning object” error when build form in AX7

Error example :
When build the project contains new custom form and datasource “CustInvoiceJour” , i encountered error missing module reference for EDT logisticsAddressing.


Solutions :
Find the object using search function, then you can see the model reference for that object. After that, update your model parameters and checklist the missing references.


The new model that my project referenced to is using Extension Model approach.