Tuesday, 18 August 2015

"DMF1942  : Access is denied for the user dixf/DMF AX2012



Resolution for the issue

"DMF1942   at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelperService.Authorization.AuthorizationManager.CheckAccessCore(OperationContext operationContext)"


Doing the following steps:

1.    Added  AOS Service Account and DIXF Service Account (read/write access) to the folder specified in DMF parameters

2. Added  these service accounts to local group “Microsoft Dynamics AX Data Import Export Framework Service”

3.  Restarted the server

4. Restart  "Dynamics AX Data Import/Export framework service.


Gudidevuni, Mallikarjun 

Tuesday, 11 August 2015

How to use AXBuild.exe tool in AX 2012 R3

How to use AXBuild.exe tool in AX 2012 R3 

Below are the steps for using AXBuild.exe tool 

Use: This tool is used to do parallel compilation of AOS objects (Full compile).

Location : c \Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin folder


Step1 : Run command prompt.
Step 2: CD c \Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin folder

Step3: AXBuild.exe xppcompileAll /aos=01 /workers=4

Note: above aos=01 is the name of aos as shown below. 

Monday, 11 May 2015

Microsoft Dynamics AX 2012 R3 Financials - General Ledger Setup

Microsoft Dynamics AX 2012 R3 Financials - General Ledger Setup


Below are the basic setups for GL
1.       Setup legal entity
a.       County
b.      Language
c.       Date time
d.      Organization administrationàArea pageàLegal entity
e.     
2.       Organizational hierarchy (optional)
a.       Purpose (centralized payment, organizational chart, etc)
b.      Organization administrationàArea pageà Organizational hierarchy
c.      
3.       Number sequence
a.       Manual
b.      By Wizard (for all the maters [modules])
c.       Scope parameters
                                                               i.      Company ( we can give the reference to a module )
                                                             ii.      Legal entity ( we can’t give the reference )
d.      Organization administrationàArea pageà Number sequences  

4.       Financial dimensions
a.       System defined (department, customer, vendor, worker)
b.      User defined (Custom)
c.       General ledgeràArea pageà SetupàFinancial dimensions
5.       Accounting structure
a.       Main accounts
b.      Financial dimensions (to validate the data or for reporting )
c.       General ledgeràArea pageà Setupàchart of accountsàconfigure account structures
d.     
6.       Chart of accounts (shareable)
a.       Main accounts
b.      General ledgeràArea pageà  Setupàchart of accountsàChart of accounts
c.      
7.       Link to legal entity (Ledger form)
a.       Accounting structure
b.      Chart of accounts
c.       Currency
d.      Exchange rate
e.      Fiscal calendar
f.        General ledgeràArea pageà Setupàledger
g.      
8.       Set up currency
a.       Accounting currency (1 for company) Ledger form
b.      Reporting currency (1 for company) ledger form
c.       Triangulation currency (1 for company)
                                                               i.      If there is no direct conversion between two currencies then we use the triangulation currency to act as mediator currency.
                                                             ii.      E.g. let’s say we need to convert NOK to USD, in that care we need to set EUR as triangulation currency and convert NOK to EUR and then EUR to USD.
d.      Display currency (this is mainly for reporting purpose and is temporary).
9.       Exchange rate (shareable)
a.       From and to Currency
b.      Quotation (1, 10, 100 units)
c.       Start date
d.      Exchange rate
10.   Revaluation accounts (only if you are using multiple currency)
a.       Unrealized Gain / Loss ( Need to run Forex batch job, these are projections but not real)
b.      Realized Gain / Loss ( Actuals, real)         
11.   Fiscal calendar (Shareable)
a.       Fiscal periods
                                                               i.      Name
                                                             ii.      Start and end date
                                                            iii.      Interval (day / month / year)
b.      Link with legal entity (Ledger )
                                                               i.      Period code
1.       Opening (closed )
2.       Operating (open)
3.       Closing (on hold)
                                                             ii.      Module level access ( All / none /  user group)
12.   Journal Names
a.       Journal types (Daily, etc)
b.      Voucher number ( number sequence )
c.       Private (to restrict access e.g. for specific use or user group)
d.      Approval ( manual / workflow)
e.      Posting restrictions (All / user / user group)
f.        Journal control ( ledger / customer / vendor/ fixed asset / bank / job)
13.   General Journal
a.       Daily journal ( with or without work flow )
b.      Periodic journal
c.       Template (amount / percentage )
d.      Posting journal
e.      Reverse the transaction
14.   Audit trails
a.       Voucher transaction



Happy 
                                               



Wednesday, 6 May 2015

AX 2012 : Custom Service for importing Sales Agreement data

Custom Service for importing Sales Agreement data : AX2012


Microsoft Dynamics AX 2012 – WCF Custom Services for importing header and line data scenario. 
In this scenario, I will show you how to create sales agreements using custom WCF service. 
We will start with the data models, below are the list of data models used to create sales agreement.
Data model :
1. AgreementHeader
2. SalesAgreementHeader
3. AgreementLine
4. InventDim
5. AgreementLineQuantityCommitment

Classes: 
1. MkSalesAgreementService (Service class)
2. MkAgreementLineContract ( AgreementLines contract class)
3. MkSalesAgreementContract (Agreement Header contract class).

First of all we will start with creating a Contract class for Agreement Header. 
MkSalesAgreementContract : Data contract class
[DataContractAttribute]
public class MkSalesAgreementContract
{
    SalesAgreementId        lSalesAgreementId;
    CustAccount             lCustAccount;

    //list for Agreement Lines
    List                    agreementLines;

}
//Data member for SalesNumberSequence.
[DataMemberAttribute]
public SalesAgreementId SalesNumberSequence(SalesAgreementId _SalesAgreementId = lSalesAgreementId)
{
    lSalesAgreementId = _SalesAgreementId;
    return  lSalesAgreementId;
}
//Data member for CustAccount
[DataMemberAttribute]
public CustAccount CustAccount(CustAccount _CustAccount = lCustAccount)
{
    lCustAccount = _CustAccount;
    return  lCustAccount;
}
//Data member for Agreement Lines data, here we are passing the agreement lines class as parameters
[AifCollectionTypeAttribute('return', Types::Class, classStr(MkAgreementLineContract)), DataMemberAttribute]
public List AgreementLine(List _AgreementLine = agreementLines)
{
    agreementLines = _AgreementLine;
    return agreementLines;
}

now, we will build the data contract class for Agreement Lines.
MkAgreementLineContract :   Data contract class
[DataContractAttribute]
public class MkAgreementLineContract
{
    AgreementHeaderRecId    lAgreement;
    EffectiveDate           lEffectiveDate;
    ExpirationDate          lExpirationDate;
    CommitmentType          lAgreementLineType;
    RefRecId                lCategory;
    ItemId                  lItemId;
    LineNum                 lLineNumber;
    InventQtyJournal        lqty;
}
[DataMemberAttribute]
public AgreementHeaderRecId Agreement(AgreementHeaderRecId _Agreement = lAgreement)
{
    lAgreement = _Agreement;
    return  lAgreement;
}
[DataMemberAttribute]
public CommitmentType AgreementLineType(CommitmentType _AgreementLineType = lAgreementLineType)
{
    lAgreementLineType = _AgreementLineType;
    return  lAgreementLineType;
}
[DataMemberAttribute]
public RefRecId Category(RefRecId _Category = lCategory)
{
    lCategory = _Category;
    return  lCategory;
}
[DataMemberAttribute]
public EffectiveDate EffectiveDate(EffectiveDate _EffectiveDate = lEffectiveDate)
{
    lEffectiveDate = _EffectiveDate;
    return  lEffectiveDate;
}
[DataMemberAttribute]
public ExpirationDate ExpirationDate(ExpirationDate _ExpirationDate = lExpirationDate)
{
    lExpirationDate = _ExpirationDate;
    return  lExpirationDate;
}
[DataMemberAttribute]
public ItemId ItemId(ItemId _ItemId = lItemId)
{
    lItemId = _ItemId;
    return  lItemId;
}
[DataMemberAttribute]
public LineNum LineNum(LineNum _lineNum = lLineNumber)
{
    lLineNumber = _lineNum;
    return lLineNumber;
}
[DataMemberAttribute]
public InventQtyJournal Qty(InventQtyJournal _qty = lqty)
{
    lqty = _qty;
    return lqty;
}

and finally we will build the service class 
MkSalesAgreementContract : Service class
class MkSalesAgreementService
{
}
we will create a service to be assessed from any external system
[SysEntryPointAttribute(true)]
public SalesAgreementId createSalesAgreement(MkSalesAgreementContract _sAgreement)
{
    MkSalesAgreementContract       lAgreementContract;
    MkAgreementLineContract        lAgreementContractLine;  
    SalesAgreementHeader            lSalesAgreementHeader;
    //AgreementLine                   lAgreementLine;
// // as AgreementLine is Abstract table we can not insert data directly, hence we need to insert into child table.
    AgreementLineQuantityCommitment lAgreementLine;
    ListIterator                    literator;
    List                            lAgreementList;
    LineNum                         lineNum;
    SalesAgreementForm              salesAgreementForm;

    try
    {
        ttsbegin;

        lSalesAgreementHeader.clear();
        lSalesAgreementHeader.initValue();
        //salesAgreementForm = SalesAgreementForm::construct();
        lSalesAgreementHeader.SalesNumberSequence   = _sAgreement.SalesNumberSequence() ? _sAgreement.SalesNumberSequence() : MkSalesAgreementService::getAgreementID();
        //lSalesAgreementHeader.DefaultAgreementLineType = salesAgreementForm.parmDefaultCommitmentType();
        lSalesAgreementHeader.CustAccount   = _sAgreement.CustAccount();
       //Mallik Mandatory fields for creating Agreement header, these can be data members methods 
        lSalesAgreementHeader.AgreementClassification = 22565421926;
        lSalesAgreementHeader.Currency  = "CAD";


        if (lSalesAgreementHeader.validateWrite())
        {
            lSalesAgreementHeader.insert();

            literator = new ListIterator(_sAgreement.AgreementLine());

            while (literator.more())
            {
                //lAgreementLine = literator.value();
                lAgreementContractLine = literator.value();
                lineNum++;

                lAgreementLine.clear();
                lAgreementLine.initValue();
                lAgreementLine.initFromAgreementHeader(lSalesAgreementHeader);//initFromInventJournalTable(inventJournalTable);
                lAgreementLine.Agreement = lSalesAgreementHeader.RecId;//lAgreementContractLine.Agreement();
                lAgreementLine.ItemId = lAgreementContractLine.ItemId();
                lAgreementLine.Category = lAgreementContractLine.Category();
                lAgreementLine.AgreementLineType = CommitmentType::ProductQuantity; //lAgreementContractLine.AgreementLineType();
                lAgreementLine.EffectiveDate = lAgreementContractLine.EffectiveDate();
                lAgreementLine.ExpirationDate = lAgreementContractLine.ExpirationDate();
                lAgreementLine.CommitedQuantity = lAgreementContractLine.Qty();
                lAgreementLine.LineNumber = lineNum;

                if (lAgreementLine.validateWrite())
                {
                    lAgreementLine.insert();
                    lAgreementLine.salesAgreementHeader().update();
                }
                else
                {
                    throw error("@SYS18447");
                }

                literator.next();
            }
        }
        else
        {
            throw error("@SYS18447");
        }

        ttscommit;
    }
    catch
    {
        return "";
    }

    return lSalesAgreementHeader.SalesNumberSequence;
}

after building the all x++ logic, it's time to create a service, add the service to ServiceGroup and deploy the service.
Now we are into final step to use the above service/ consume the WCF Custom service in .Net application.
here we go....

Create a console C# project
 add the Service Reference to the project ( WSDL URL of inbound port) 

and the C# code goes as below .......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MkSalesAgreements.ServiceReference1;

namespace MkSalesAgreements
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                DateTime EffectiveDate;
                // Get the value of date1, for example, here it is hard-coded
                EffectiveDate = Convert.ToDateTime("10/01/2015");
                // Calculate new date
                DateTime ExpirationDate = EffectiveDate.AddMonths(3);// AddDays(20);
                // Now, print the newdate or use it in any way you want


                MkSalesAgreementServiceClient client = new MkSalesAgreementServiceClient();

                CallContext context = new CallContext();
                context.Company = "USMF";
                Console.WriteLine("Object Created Success!");
                MkSalesAgreementContract agreements = new MkSalesAgreementContract();

                agreements.SalesNumberSequence = "SAG-000025";
                agreements.CustAccount = "BGRS-00003";
                

                MkAgreementLineContract[] agreementLines = new MkAgreementLineContract[2];

                agreementLines[0] = new MkAgreementLineContract();
                //agreementLines[0].Agreement = "SAG-000016";
                agreementLines[0].ItemId = "A0001";
                agreementLines[0].Qty = 100;
                //agreementLines[0].AgreementLineType = 1;
                agreementLines[0].EffectiveDate = EffectiveDate;
                agreementLines[0].ExpirationDate = ExpirationDate;

                agreementLines[1] = new MkAgreementLineContract();
                agreementLines[1].ItemId = "BA-Services";
                agreementLines[1].Qty = 99;
                //agreementLines[1].AgreementLineType = 1;
                agreementLines[1].EffectiveDate = EffectiveDate;
                agreementLines[1].ExpirationDate = ExpirationDate;

                agreements.AgreementLine = agreementLines; // add Lines to Header 
                Console.WriteLine("Lines added Success!");
                string journalId = client.createSalesAgreement(context, agreements); // call the createSalesAgreement method

                Console.WriteLine("JournalId:" + journalId);

                Console.WriteLine("Success! Mallik.. Happy Learning !!!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
            }

            Console.ReadLine();
        }
    }
}


Points to Note:
1. as AgreementLine is Abstract table we can not insert data directly, hence we need to insert into child table.
2. The child table data is passed as a class object of child contract class. 

for more information about custom services see here 










Tuesday, 21 April 2015

AIF Calling CustCustomerService.Update using WCF from C#

Create and configure the Inbound integration port for CustCustomerService.Update

  1. Open the Inbound ports form. Click System administration > Setup > Services and Application Integration Framework > Inbound ports.
  2. Click New.
  3. Name the new integration port CRM2AXCustCustomerService.
  4. In the Adapter list in the Address group, select NetTcp.
  5. On the Service contract customizations FastTab, click Service operations.
  6. In the Select service operations form, select CustCustomerService.create,CustCustomerService.read and CustCustomerService.update in the Remaining service operations list. Click the left arrow to move the service operation to the Selected service operations list. Then, close the form.
  7. You can modify the document data policy to match the fields that you want to return in the response. If you do not specify a data policy, then all sales order schema elements are included in the response message by AIF. If you specify a data policy but do not modify the default data policy, then only the default elements are included in the sales order schema.
  8. Activate the integration port.
  9. Make note of the address that is displayed in the WSDL URI text box.
  10. Close the Inbound ports form.
Create a C# project to consume the WCF service 
  1. Open Visual Studio and create a new console application project in Visual C#. Name the project "CRM2AXMKClient".
  2. In Solution Explorer, right-click the project name and then click Add Service Reference.
The Add Service Reference dialog box opens.
  1. In the Address text box, enter the WSDL URI from the port that you created in the previous section. For example:
4.  http:// XXXXMKAOSXX:8101/DynamicsAx/Services/CRM2AXCustCustomerService
  1. Click Go. Wait for Visual Studio to find the service.
  2. Click OK to close the dialog box.
  3. Open Program.cs. In the code editor, replace the code with the following C# code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CRM2AXUpdateCustCustomerService
{
    class Program
    {
        //Mallik Code to updated Customer using WCF (CustCustomerService.update()) 20/04/2015
        //  The customer service is date effective because it contains the DirPersonName, DirOrganizationName,
        //DirPartyLocation, etc. tables which have their ValidTimeStateFieldType properties set to something other than None.

        //Date effective services have properties added at the document level (the highest level in the service)
        //to indicate how you want to set the date effective entities.  
        //The properties are ValidTimeStateType, ValidAsOfDateTime, ValidFromDateTime and ValidToDateTime.
        //Either you can set those at the document level or you can set the date effective fields on each entity in the service
        //that is date effective. 

        //In the example code below, I call the read method to retrieve a customer and then I create a
        //new instance of a customer, set the date effective properties on the document according
        //to what they are on the retrieved customer and then update the CreditMax field on the customer.

        static void Main(string[] args)
        {
            string customer = "MK2";

            //ServiceReference1 is the name of ServiceReferance added to the project.
            ServiceReference1.CustomerServiceClient proxy = new ServiceReference1.CustomerServiceClient();
            var context = new ServiceReference1.CallContext() { Company = "USMF" };
            ServiceReference1.AxdCustomer foundCustomer = null;
            try
            {
                foundCustomer = proxy.read(context, readCritera(customer));
                Console.WriteLine("Read worked");
                updateCustomer(foundCustomer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        } // end of Main


        private static ServiceReference1.EntityKey[] readCritera(string customerAccount)
        {
            ServiceReference1.AxdEntity_CustTable custTable = new ServiceReference1.AxdEntity_CustTable();
            ServiceReference1.EntityKey[] entityKeyList = new ServiceReference1.EntityKey[1];
            ServiceReference1.EntityKey key = new ServiceReference1.EntityKey();
            ServiceReference1.KeyField[] keyFields = new ServiceReference1.KeyField[1];
            ServiceReference1.KeyField keyField = new ServiceReference1.KeyField();
            keyField.Field = "AccountNum";
            keyField.Value = customerAccount;
            keyFields[0] = keyField;
            key.KeyData = keyFields;
            entityKeyList[0] = key;
            return entityKeyList;
        }

        private static void updateCustomer(ServiceReference1.AxdCustomer customer)
        {
            ServiceReference1.CustomerServiceClient proxy = new ServiceReference1.CustomerServiceClient();
            ServiceReference1.CallContext context = new ServiceReference1.CallContext();
            context.Company = "USMF";
            ServiceReference1.AxdEntity_CustTable custTable = customer.CustTable[0];

            ServiceReference1.AxdCustomer axdCustomer2 = new ServiceReference1.AxdCustomer();
            axdCustomer2.ValidTimeStateType = customer.ValidTimeStateType;
            axdCustomer2.ValidTimeStateTypeSpecified = true;
            axdCustomer2.ValidAsOfDateTime = customer.ValidAsOfDateTime;
            axdCustomer2.ValidFromDateTime = customer.ValidFromDateTime;
            axdCustomer2.ValidToDateTime = customer.ValidToDateTime;

            ServiceReference1.AxdEntity_CustTable custTableNew = new ServiceReference1.AxdEntity_CustTable();
            custTableNew._DocumentHash = custTable._DocumentHash;
            custTableNew.RecId = custTable.RecId;
            custTableNew.RecVersion = custTable.RecVersion;
            custTableNew.action = ServiceReference1.AxdEnum_AxdEntityAction.update;
            custTableNew.actionSpecified = true;
            custTableNew.CreditMax = custTable.CreditMax + 10;
            custTableNew.CreditMaxSpecified = true;
            custTableNew.CustGroup = custTable.CustGroup;
            axdCustomer2.CustTable = new ServiceReference1.AxdEntity_CustTable[1] { custTableNew };

            try
            {
                proxy.update(context, readCritera("MK2"), axdCustomer2);
                Console.Write("Worked");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                Console.ReadLine();
            }
        }
    }
}

For Item /Product Refer 

https://blogs.msdn.microsoft.com/dynamicsaxscm/2011/07/06/product-item-data-management-services/



How to Disable “Advanced Filter or Sort” and Enforce Custom Filters on Any D365FO Form

 In Dynamics 365 Finance and Operations, users can apply filters through the “Advanced filter or sort” feature found under the Options tab...