Home

Thursday, July 20, 2017

Find party Email phone and fax based on type ax 365

class TestRunnableClass
{      
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {    
        /*LogisticsElectronicAddress      logisticsElectronicAddress;
        int64                           party;
        party                        = VendTable::find(PurchTable::find("P000000052").OrderAccount).Party;
        Phone ph=    LogisticsElectronicAddress::findPrimary( VendTable::find(PurchTable::find("P000000052").OrderAccount).Party, LogisticsElectronicAddressMethodType::Phone).Locator;
        info(strFmt("primary is --%1",ph));*/

     
        LogisticsElectronicAddress      logisticsElectronicAddress;
        VendTable vendtable;
        vendTable = VendTable::find("V000000020");
        select Location, Type, Locator,Description from logisticsElectronicAddress
        where logisticsElectronicAddress.Location == DirPartyLocation::findOrCreate(vendTable.Party, 0).Location
        && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email
        && logisticsElectronicAddress.IsPrimary == NoYes::Yes;
        info(strFmt("Email is-%1 .. Contact is-%2",logisticsElectronicAddress.Locator,logisticsElectronicAddress.Description));
           
       
    }

}

Ax 365 ssrs report handler class

class ABC_purchPurchaseOrderHandler
{
    
    
        /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(PurchPurchaseOrderHeader), DataEventType::Inserting)]
    public static void PurchPurchaseOrderHeader_onInserting(Common sender, DataEventArgs e)
    {
        PurchPurchaseOrderHeader    tmpTable = sender;
        VendTable                   vendTable;

        vendTable                        = VendTable::find(PurchTable::find(tmpTable.PurchId).OrderAccount);
        tmpTable.ABC_vendPhone           = PurchTable::find(tmpTable.PurchId).vendorPhone();
        tmpTable.ABC_vendTeleFax         = PurchTable::find(tmpTable.PurchId).vendTable_InvoiceAccount().telefax();
        tmpTable.ABC_DlvMode             = PurchTable::find(tmpTable.PurchId).DlvMode;
        tmpTable.ABC_PayTerms            = PurchTable::find(tmpTable.PurchId).Payment;
        tmpTable.ABC_SupplierDescription = PurchTable::find(tmpTable.PurchId).vendorName();
        tmpTable.ABC_Buyer               = HcmWorker::find(PurchTable::find(tmpTable.PurchId).WorkerPurchPlacer).name();
        tmpTable.ABC_InvoiceDescription  = dirParty::findPostalAddressByRole(vendTable.Party, LogisticsLocationRoleType::Invoice).displayLocationDescription();
        tmpTable.ABC_BillingAddress      = dirParty::findPostalAddressByRole(vendTable.Party, LogisticsLocationRoleType::Invoice).Address;
        tmpTable.ABC_Contact             = ABC_purchPurchaseOrderHandler::getContactDeatils(vendTable.Party, LogisticsElectronicAddressMethodType::Email).Description;
        tmpTable.ABC_vendPhone           = ABC_purchPurchaseOrderHandler::getContactDeatils(vendTable.Party, LogisticsElectronicAddressMethodType::Phone).Locator;
       
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(PurchPurchaseOrderTmp), DataEventType::Inserting)]
    public static void PurchPurchaseOrderTmp_onInserting(Common sender, DataEventArgs e)
    {
        PurchPurchaseOrderTmp           tempTable = sender;
        VendPurchOrderJour              vendPurchOrderJour = VendPurchOrderJour::findRecId(tempTable.JournalRecId);
        CustVendExternalItem            custVendExternalItem;


        select ExternalItemTxt from custVendExternalItem
            where custVendExternalItem.ItemId == tempTable.ItemId &&
            custVendExternalItem.ExternalItemId == tempTable.ExternalItemNum &&
                custVendExternalItem.CustVendRelation == vendPurchOrderJour.purchTable().InvoiceAccount;

        tempTable.ABC_ExternalItemName  = custVendExternalItem.ExternalItemTxt;
    }

    /// <summary>
    /// Get the party contact details
    /// </summary>
    /// <param name = "_party"></param>
    /// <param name = "_type"></param>
    /// <returns></returns>
    public static LogisticsElectronicAddress getContactDeatils(RefRecId _party, LogisticsElectronicAddressMethodType _type)
    {
        LogisticsElectronicAddress      logisticsElectronicAddress;

        select * from logisticsElectronicAddress
            where logisticsElectronicAddress.Location == DirPartyLocation::findOrCreate(_party, 0).Location
                && logisticsElectronicAddress.Type == _type
                && logisticsElectronicAddress.IsPrimary == NoYes::Yes;

        return logisticsElectronicAddress;
    }

}

Friday, March 31, 2017

D365 | Recurring Integration - Application ID

When you create a recurring data job in Dynamics 365 (AX7) you will be asked for an application id in the "Setup authorization policy" tab.


If you don't have already created your application id within the azure active directory you need to follow these steps to get it done. This relates to the new azure portal: https://portal.azure.com


1- Login to the azure portal and click on azure active directory.

             

2- Manage -> App registration and click ADD

             

3- In the Create dialog enter a name, select Application type Native and provide a uri. For example the address of your onebox development environment: https://usnconeboxax1aos.cloud.onebox.dynamics.com
Click Create - and wait a second

       
4- Navigate to the newly created app - now you should already see the application id that you're looking for

 

5- Before you continue in D365 click on required permissions - Add

6- Select: Microsoft Dynamics ERP (Microsoft.ERP) as the API and select permissions as needed and click select and done

7- Now your required permissions should look like this


Copy the application id and enter it in Dynamics 365. Now you can go on with the recurring integration.