Saturday, 27 June 2015

Get the data from all companies in Microsoft Dynamics AX 2012

Now you can get the data from all the companies through query...using "cross company" keyword
Example:
select crosscompany accountNum from custTable;

Friday, 26 June 2015

Role-based security in Microsoft Dynamics AX [AX 2012]

Basics of Security Feature in AX:

In role-based security, access is not granted to individual users, only to security roles. Users are assigned to roles. A user who is assigned to a security role has access to the set of privileges that is associated with that role. A user who is not assigned to any role has no privileges.
                In Microsoft Dynamics AX, role-based security is aligned with the structure of the business. Users are assigned to security roles based on their responsibilities in the organization and their participation in business processes. The administrator grants access to the duties that users in a role perform, not to the program elements that users must use.
                Because rules can be set up for automatic role assignment, the administrator does not have to be involved every time that a user's responsibilities change. After security roles and rules have been set up, business managers can control day-to-day user access based on business data.


1. Security Roles
All users must be assigned to at least one security role in order to have access to Microsoft Dynamics AX. The security roles that are assigned to a user determine the duties that the user can perform and the parts of the user interface that the user can view.

2.Process Cycles:
A business process is a coordinated set of activities in which one or more participants consume, produce, and use economic resources to achieve organizational goals. Process cycles are used for organization only. The process cycles themselves cannot be assigned to roles.

3.Duties:
Duties correspond to parts of a business process. The administrator assigns duties to security roles. A duty can be assigned to more than one role.You can assign related duties to separate roles. These duties are said to be segregated. 

4. Privileges:
In the security model for Microsoft Dynamics AX, a privilege specifies the level of access that is required to perform a job. Privileges can be assigned directly to roles. However, for easier maintenance, it is  recommend that you assign only duties to roles.

5. Permissions:
Each function in Microsoft Dynamics AX, such as a form or a service, is accessed through an entry point. Menu items, web content items, and service operations are referred to collectively as entry points.In the security model for Microsoft Dynamics AX, permissions group the securable objects and access levels that are required to run a function. This includes any tables, fields, forms or server side methods that are accessed through the entry point.Only developers can create or modify permissions.Permissions may be Read,Write,View/Edit etc set on menu items.

Creating a simple SSRS report with UI Builder,Controller,contract and DP class in Microsft Dynamisc AX 2012

Here are the steps:

>> UI Builder Class:

1. Create a new class. Open AOT à Classes, Right Click on Classes and select New Class. Name it as SSRSTestUIBuilder.
2.Open the Class declaration by right clicking on it and selecting View code.
3.Write the following code: 
public class SSRSTestUIBuilder extends SrsReportDataContractUIBuilder
{

}

>> Contract Class:

4. Now create a new class called Contract Class. Example: TestContract()

[SysOperationContractProcessingAttribute(classStr(SSRSTestUIBuilder))] //Important Line which connects UI Builder and contract class.
public class TestContract()
{

}

5.In contract class add the parameter methods.
Example: 
public CustAccoutn parmAccountNum(CustAccount AccountNum _AccountNum )
{       
         AccountNum = _AccountNum ;      
         return AccountNum ;
}

Note : Based on the requirements add as much as parameters methods needed.


>> Controller Class:


6.Create a controller class.
Example: 
public class SSRSTestController extends SrsReportRunController
{
//define the required declarations
}

7. Create a main method and write the following code:
public static client void main(Args args)
 {
    //define the new object for controller class
    SSRSTestController ssrsTestController;
    ssrsTestController = new SSRSTestController();
    //pass the caller args to the controller
    ssrsTestController.parmArgs(args);
    //set the report name and report design to run
    ssrsTestController.parmReportName(ssrsReportStr(SSRSSessionQuery,Design));
     //execute the report
    ssrsTestController.startOperation();
 }

>> Back to UI-BUILDER:

8. Based on different scenarios, different methods are overridden as shown:

public void build()
{
    DialogGroup dlgGrp;   
     //get the current dialog
    Dialog      dlg = this.dialog();      

    //make required modifications to the dialog
    dlgGrp = dlg.addGroup('Dates'); 
    dlgGrp.columns(2);  
    dlg.addField(identifierStr(FromDate));
    dlg.addField(identifierStr(ToDate));   
       
    dlgGrp = dlg.addGroup('Customer'); 
    dlg.addField(identifierStr(CustAccount));   
}

also use this code in build method to bind data:

//get the report data contract object

contract = this.dataContractObject();
    
//associate dialog field with data contract method

this.addDialogField(methodStr(SSRSTestContract,parmCustAccount), contract);


9.Over-ride a lookup method:

public void lookupCustAccount(FormStringControl _formStringControl)
{   

    Query query = new Query();

    QueryBuildDataSource DS;  
  
    SysTableLookup sysTablelookup;

    //create a table lookup    

    sysTablelookup = SysTableLookup::newParameters(tableNum(CustTable),_formStringControl);

    sysTablelookup.addLookupfield(fieldNum(CustTable,AccoutNum));
    
    //create a query

    DS = query.addDataSource(tableNum(CustTable));

    DS.addRange(fieldNum(CustTable,AccoutnNum)).value('001');

    //assign the query and call lookup

    sysTablelookup.parmQuery(query);

    sysTablelookup.performFormLookup();
}


10.Now override the postBuild method:

public void postBuild()
{
    DialogField dlgCustGroup;
    
    super();
    
    //get the field to override by providing the data contract object and the associated 

attribute/method

    dlgCustGroup = this.bindInfo().getDialogField(this.dataContractObject(),

                methodStr(SSRSTestContract,parmCustAccoutn));

    //register the method we want to override

    dlgCustGroup.registerOverrideMethod(

          methodStr(FormStringControl, lookup),

          methodStr(SSRSTestUIBuilder,lookupCustAccount),this);    

}

>> RDP(Report data provider):

Now create a class called TestDemoDP class, note that the name of the class must end with 'DP'.

(i) class declaration:

public TestDemoDP ()
{
   # define the required variables
   TempTable     tmpTable;
}

(ii) getTemporaryTable(): Here you need to create a temporary table (Go to AOT create a table and name it ''TempTable' and set the Table Type property as 'TempDB')

public TempTable getTemporaryTable()
{
   select * from tmpTable;
   return tmpTable;
}

(iii) processReport():

public void processReport()
{
     //Define Contract method
     //write the business logic as per scenarios
     while select AccountNum from custTable
              where custTable.AccountNum == '001';
    {
        //insert into temp table
        tmpTable.AccountNum = custTable.AccountNum;
        tmpTable.insert()l
    }  

}

Now you are ready with the fully loaded SSRS report which contains UI-Builder,contract,controller,and DP class.

Note: After having created all these you need to create design in visual studio and connect these code there.For more information refer my earlier blogs on SSRS reports.








Wednesday, 24 June 2015

Accounting Cycle in Microsoft Dynamics AX 2012

As we know that organization operations such as purchases, sales should be recorded as transactions that credits/debits amounts from one accounts to others. The motto is to learn all the steps from the business operation till the financial statement. This flow is called the accounting cycle. These are the core responsibilities of an accountant person.
It can also be defined as the accounting cycle is the sequence of procedures used to keep track of what has happened in the business and to report the financial effect of those things. 
These are the things which occurs in accounting cycle:
1. Operations: Purchases/Sales occurs in  business.
2. Computerize/Record the purchase/sales: It is necessary to keep track of all things, so that accounting Dept has a record of all the information about sales and purchases that occurs in business.
3. Analyse: The most important step is to analyse the things.The goal is to write correct transactions.We need to analyse things such as “What happened?” , “What accounts will change?”(Asset, Liability, Owner’s Equity) , “How will they change?” (Will the accounts increase or decrease?) , "Debit or Credit?" (Debit is “good” for the company, Credit is “bad” for the company.).
4. Journalize: The main journal for an accountant is the General Journal. General Journal is used to write transactions to it.Accountant hold this responsibility.
5.Post: We need to post the transactions, because amounts are transferred from one account to another.
6.Trial Balance: A trail balance is a list of all accounts and their balances.checks the accounting equation: Assets = Liabilities + Owner’s Equity.
7.Adjustments: Adjustments are nothing but changes in any purchases or orders made or you can say that they are entries are made at the end of a period to track revenue and expenses.
8.Financial Statements: They are the Balance Sheet, Income Statement, and Cash Flow Statement.
9.Close: The accountant closes the transactions.The reason for the closing entries is to ensure that each revenue and expense account will begin the next accounting year with a zero balance.


Tuesday, 23 June 2015

Classes and Tables used in sales order process in Microsoft Dynamics AX 2012

  • Classes,Tables and Methods used to post the sales orders:
  1. SalesTableType and SaleslineType classes will get called while creating the orders.
  2. SalesFormLetter classes will be used to post the sales order at various document status(packing,invoice etc).
  3. SalesParm tables are used to prepare the data for posting.
  4. CustConfirmJour, CustConfirmTrans - when a sales order gets confirmed
  5. CustPackingSlipJour, CustPackingSlipTrans - when a packing slip is posted.
  6. CustInvoiceTable,CustInvoiceTrans - when an invoice is posted.



Import demo data in Microsoft Dynamics AX 2012

1.Download demo file and definition file. Extract and save these files in any folder on your local computer.

2.Return to Microsoft Dynamics AX. Make sure which company you want to import. Go to Administration> Periodic > Data export/import > Import. The Import options form opens.

3.In the File name field, enter the path to the downloaded demo file. Click OK.

Note : The process may take up to 10 minutes. When import is finished, the Infolog message appears stating that the file has been imported.That’s all! Our selected company has demo data.

Set a default company in Microsoft Dynamics AX 2012

1.Click the Microsoft Dynamics AX menu button and then click Tools > Options…
2.The Options form opens. On the General tab, find the Start company accounts field
and select AX company from the drop-down list. Close the form.