Wednesday, 9 October 2013

Creating Role Center in Ax 2012


Today , I will share " Creation of a Role Center Page " as easy as you like , I'll start with a brief introduction just to make sure you have a brief understanding of role centers.

Introduction : 

The role center page is displayed as the home page for the Home site in Enterprise Portal. It is the first page that users see when they access Enterprise Portal. It is also displayed in the Microsoft Dynamics AX client.
Enterprise Portal contains role center pages for the various roles that users can have in Microsoft Dynamics AX. If a user is not assigned to a specific role, the default role center page is displayed.

Creating Role Center Page : 

Below is the step by step creation of a role center page . 


On the Home page of the EPDefaultRoleCenter , Go to Site Actions => More options as can be seen in the above screen shot.



From the next screen select the Web Part Page template and click on the Create button .







On the next step give the name for your role center page , pick a layout template and set the document library drop down to Enterprise Portal then hit the Create button.









You can set the layout of your RoleCenterPage by adding web parts , to add web part click on the Add a WebPart link.


Here , you can select any of the WebPart type from the available Categories and then click on the Add button.


Once the Web Part is added you can always modify it by clicking on that small inverted triangle as highlighted in the image above , this will open the drop down where you can select Edit Web Part option .









The Edit Web Part option opens the form for that web part where you can customize the web part as per your need .

























Now , In the AOT under the Web node go to Web Menu Items => URls

Right click and select New URL option .







Now , set the properties for the newly created URl 

  1. Specify the Name for the URL. Use a name that specifies the page that the URL will point to.
  2. Specify a label for the page.
  3. Specify the URL, with the following form:
  Enterprise%20Portal/PageName.aspx 

  You can also use the browse button to open a dialog box that lets you select the page. 
  Navigate to the module site and document library that contains the page. 
  Select the page and then click OK.
   
 4. Set the Home Page property to Yes.
 5. Fill the Page Definition property by giving the desired page definition name.
 6. Save the new URL Web Menu Item.

























Right Click on the newly created URl and select the Import page option as shown above.


This will Create the page definition with the same name as given in the Page Definition property for the URI Menu item earlier.


Now go to System administration => Common => User Profiles.

On the User Profiles form click on the New button.

Fill the Profile ID  , Description and Paste the Name of your URl Web Menu Item  and hit the Close button on this form.

Finally , you can view your role center in the browser by clicking on the View role center button on the User Profiles form . 

I believe it was helpful .

Thursday, 4 July 2013

How to Install EP in AX 2012

Hi Guyz,

I found a great post on "Installing EP in AX 2012"  and it was worth sharing about .....

The post can be found here :

http://dynamicsaxcloud.blogspot.com/2013/04/enterprise-portal-ep-in-dynamics-ax-2012.html

Monday, 3 June 2013

Reference LookUp in Ax 2012


Creating a Simple Reference Lookup :


We can create a simple reference lookup for reference controls using the SysReferenceTableLookup class . These are the steps to do so.

  1.  Create the SysReferenceTableLookup Object.
  2.  Create the query which will be used to select the lookup data.
  3.  Add the fields to be shown in the lookup.
  4.  Perform the lookup.
 
I will demonstrate by a simple example as shown below.

We need to override the lookupReference method of the field at the form dataSource level or a Control at the form design level . It is better to override at the datasource level instead of design level.


Just copy the code above and make  necessary changes according to your scenario and your lookup is ready to Go !!

Keep Enjoying ... 

Friday, 31 May 2013

Using the MultiSelection Helper Class in AX 2012


MultiSelection Helper :

 
Think of a Scenario in which you have to select all the records in a grid by means of that small check box at the top left corner of a grid and based on that selection you have to make decisions on the records returned .

Although , it looks very simple but in reality its not the case . But you don't need to worry now because the
" MultiSelection Helper Class " does this for you , in a fairly simple way .

Just have a look at the example given below.

In case of a form Override the Clicked event of the button that is used to fetch the records  and replace this code to that method with your own data source.

void clicked()
{
    CustPaymModeTable custPaymModeTablelocal;
    MultiSelectionHelper helper = MultiSelectionHelper::construct();

    helper.parmDatasource(custPaymModeTable_ds);
    custPaymModeTablelocal = helper.getFirst();
  
    while (custPaymModeTablelocal.RecId != 0)
    {
        info(custPaymModeTablelocal.PaymMode);

        custPaymModeTablelocal = helper.getNext();
    }
}

                    
The records are fetched in between the get First and get Next methods and that's where you can perform your desired Operations.

I believe it was simple .. Have Fun !!

Tuesday, 26 February 2013

Extension Framework in AX2012


Introduction:


The basic idea of extension framework is that Frameworks, and their Foundation components  must adhere to the Open-Closed principle. This principle states that “software entities should be open to extension, but closed to modification”  this means that extending framework classes should not require changes to the any framework artifacts (classes, tables, Enums).

I found a great post on this..


Enjoy ...

Wednesday, 20 February 2013

Display Methods in Ax 2012


Display Methods :


These methods are commonly used while performing a calculation or to lookup fields from another table. The
Display modifier is added before the method name that shows that the methods return value is to be displayed on forms and reports.






Please note that the return type of a display method should be of type EDT.

Usage:


The Display modifier can be used on .


  • Table methods.
  • Form methods.
  • Form datasource methods.
  • Report methods.
  • Report design methods.
Avoid complex calculations on display methods because they are called each time a form is redrawn.

I will be demonstrating the usage of display methods  by a quick example.

  • Add a display method to lookup fields from another table on a form datasource.





  • This is how the method looks.

















As , you can see the methods lookup WorkItemType from another table that is'nt available under the datasource node of this form.


  • Add the display method to a form control.


















  • Change the Data source and Data method properties of the control as follows.










It's better to write Display methods on the table level so that the same method can be used on multiple forms and reports where the table is used as a Datasource.

If the value returned is to be shown in a grid then the Display method must be written on the form datasource level as shown in our example above.

I believe it was useful ..



Thursday, 14 February 2013

Reading excel file to store data in a table in Ax 2012



   
Today I will be sharing how to read excel in Ax 2012 . I will demonstrate through a simple example.

Below is my Excel Sheet .


This is my Job that reads this excel sheet.

static void ExcelJobProduct(Args _args)
{

SysExcelApplication                    application;
SysExcelWorkbooks                   workbooks;
SysExcelWorkbook                     workbook;
SysExcelWorksheets                  worksheets;
SysExcelWorksheet                    worksheet;
SysExcelCells                              cells;
COMVariantType                       type;
ProductType                                prodType;
FileName                                     filename;
Product                                         Product;
ProductId                                     prodId;
Name                                           productType;
int                                                 row =1 ;
str                                                ProductName;
real                                              Price;
str                                               _ProductCode;


application = SysExcelApplication::construct();
workbooks = application.workbooks();

//specify the file path that you want to read
filename = "C:\\Task_2_DataSet_Normalized.xlsx";
try
{
//  Adds the file as the first document in the collection.
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}

workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(5);   // represents the current worksheet in my case it's (5)
cells = worksheet.cells();

// Fetches data from each cell that contains data.

do
{
row++;

Price       = cells.item(row, 4).value().double();
prodId      = int642str(cells.item(row, 1).value().double());
ProductName = cells.item(row, 2).value().bstr();
productType = cells.item(row, 3).value().bStr();

// Insert data into Product table based on the ProductType from ProductType table.
select prodType
     where prodType.ProductType == productType;

if(prodType.RecId != 0)
 {
    ttsBegin;
    Product.ProductCode  =  prodId;
    Product.Name              = ProductName;
    Product.ProductType   = prodType.RecId;
    Product.Price                =  Price;
    Product.insert();
    ttsCommit;
 }
type = cells.item(row+1, 1).value().variantType();
}

// Runs until the COMVarientType doesnot contains a data field.
while (type != COMVariantType::VT_EMPTY);

// Closes the Instance of Excel.
application.quit();
}


Here ,
  • SysExcelApplication  represents an instance of Excel .
  • SysExcelWorkbooks provides collection of Excel documents stored in this Class.
  • SysExcelWorkbook   provides a reference to the opened document.
  • SysExcelWorksheets represents a collection of all the worksheets in a document.
  • SysExcelWorksheet   provides a reference to a single worksheet.
  • SysExcelCells             provides reference to the collection of cells within a sheet.
  • COMVariantType      COMVarient Class is used to store various types of data .



Monday, 4 February 2013

Difference Between OLTP and OLAP

OLTP:



  • Operational data; OLTP's are the original source of the data.
  • To control and run fundamental business tasks.
  • Short and fast inserts and updates initiated by end users.
  • Relatively standardized and simple queries Returning relatively few records.
  • Backup religiously; operational data is critical to run the business, data loss is likely to entail significant monetary loss and legal liability.




OLAP:



  • Consolidation data; OLAP data comes from the various OLTP Databases.

  • To help with planning, problem solving, and decision support.
  • Periodic long-running batch jobs refresh the data.
  • Often complex queries involving aggregations.
  • Instead of regular backups, some environments may consider simply reloading the OLTP data as a recovery method.


Thursday, 24 January 2013

Parsing XML in Dynamics Ax 2012:



 Today I will be sharing "How to parse XML in AX 2012 " . I have used  XPath for navigating through the elements and attributes in XML. By the use of XPath it becomes very easy to parse an XML for selected nodes only.

 
This was my XML and I have to fetch all the Ownership prefixes for Group node having name attribute set to "GFM" and within that only that team which has name attribute set  to "Public Sector SL1" . After fetching the values of Prefixes I have to insert all those values in a table of type (tempdb) .

Now , I will show how i achieved that..

That's how my project looks..


This is my simple Job that does that all for me..


I defined my XPath in a Macro (#node) and passed that (#node) to XmlGroupnameNodeList . Have a look at this XPath ('//Team[@name="Public Sector SL1"]/Ownership/@prefix') it looks for Team node any where in the document having its name attribute set to (@name="Public Sector SL1") and within that team node it looks for the values of Ownership prefixes (Ownership/@prefix) .

I believe it was helpful....




Thursday, 6 December 2012

Unit Of Work Implementation in Dynamics AX


UNIT OF WORK:

Unit of work keeps track of everything you do during a transaction that can effect the database. It keeps track of everything that needs to be done to alter the database as a result of your work.

There is a system class called UnitOfWork Class in X++ that implements the Unit Of Work Framework. Some of it's details are given below.

Clear
 Clears all the changes
DeleteonSaveChanges
 Deletes the record on commit/save changes
InsertOnSaveChanges
 Inserts the record on commit /save changes
UpdateOnSaveChanges
 Updates the record on commit /save changes
SaveChanges
 Save the changes on the server

Implementing the Unit Of Work:

In this example we will perform bulk insertion on tables , this is where the role of Unit of work comes into play . By means of it we can insert lines against a header record without creating the header first on the basis of the Rec Id that comes as a foreign key in the child table.

Example:


In this example you can see we have created two tables :
  • Candidate 
  • Exam
Where the Exam table behaves as the header table and the Candidate tables acts as the Lines.The Screen shot below shows the relation between them.


After this step we need to set the CreateNavigationPropertyMethods Property to Yes.  As Shown in the screen shot below.


After that we need to create a new class and add a Method in it that will perform all the calculations and insertions , as shown in the screen shot below.



 Finally we need to call this method in a job. The results can be seen by opening the tables.



In this way the DataSources can be grouped as a unit of work and Ax Client has great support for it.

I believe it was helpful.  


Tuesday, 4 December 2012

Work Flow in Dynamics Ax 2012


WORKFLOW:


A Work Flow can be defined as a sequence of steps where each steps follows the precedent without any gap or delay.It can also be defined as a movement of tasks within a process. The Dynamics AX Work Flow infrastructure enables user configurable workflows in Dynamics Ax application modules with specific focus on tasks and approval workflows.



A Work Flow is designed based on the company requirements then Configured by the administrator , and run by the user.

BASIC CONCEPTS:

Work Flow Type:

It is the basic building block that can be used to create customized workflows that enforce business policies. A Work Flow type defines :
  • The Work Flow document to use.
  • Tasks and approvals that can be configured by the User.
  • Workflow categories used to assign a workflow type to a specific module.
  • Menu item and Event Handlers to be used.

Work Flow Configurations:

These are created by the application administrators that use Dynamics Ax Work Flow editor. The administrator configures the:
  • Work Flow
  • Workflow Elements.
  • Approval elements to control the flow of business document through workflow process.

Work Flow Instances:

Created by the Work Flow run time when the workflow is activated.

Work Flow Elements:

These are created in the AOT and configured by the administrator. A Work Flow structure consists of a sequence of Work Flow elements that includes:
  • Tasks
  • Approval
  • Sub-Work Flow

Developer's Role:

A Developer adds Work Flow to an existing business document or Creates new document that support Work Flow. A developer performs these steps :
  • Creates a Query for Work Flow.
  • Creates a Work Flow Category.
  • Creates a Work Flow Type.
  • Creates Work Flow elements.
  • Enables Work Flow on a Form.

Creating Query For Work Flow:

An AOT Query can be simply created under the Queries node in AOT. Right click on the queries node and  Create New Query.


for further information on queries see  here

Creating Work Flow Category:

Expand the Work Flow node and right click on the Work Flow categories node to create a new Category.


In the Property Sheet for the newly created module set it's name and module properties.

Creating Work Flow Type:

To create Work Flow type we need to run a Workflow Type wizard.
AOT--> Work Flows--> Work Flow Type  right click and then go to addins and run Work Flow Type wizard.


Create Work Flow Elements:

To Create Work Flow elements we have multiple ways . For (e.g) In order to create an Approval Element for the workflow we can run an Approval wizard as shown below.


Or you can create tasks by these steps:
AOT--> Work Flow-->Tasks-->New Task

Enabling Work Flow on a Form:

Expand the form , expand it's designs node and on the design node right click properties. On the Properties window set the following properties:

Work Flow Enabled       :        ( Yes ) 
Work Flow Data Source:        (Data Source for the Query)
Work Flow Type            :        (Work Flow Type Created)








Thursday, 22 November 2012

Exceptions in Dynamics AX 2012



Exceptions:

       
A Situation in which the flow of a program is interrupted is called exception . A program must handle them For example: If a user requests a record to be fetched and that record doesn't exists then in that case system must throw an exception. There are many types of exceptions thrown depending upon it's cause . All of them can be caught so it's a developer's decision to decide which exceptions must be handled by the system.

Some common exceptions are listed below:







Try , Throw ,Catch & Retry Statements :


Try: 

       These statements indicate the start of the block of code that you are going to handle with X++ Exception handling system . Any exception thrown in this block can be caught in the associated catch statements.

Throw:

       These statements are used to explicitly throw an exception that can be caught by the Catch statement.

Catch:

       These statements define what code is going to be executed in case of an exception being thrown . These statements come after the Try statement. It is not necessary to catch each try statement But each Try statement must have a corresponding Catch statement.

Retry:

       These statements tell the system to go back to the Try statement and attempt to execute the code again , any data loaded before the Try statement remains the same where as any data loaded after the Try statement will be refreshed.

Optimistic Concurrency Control ( OCC ) :


It is a performance enhancing function within Dynamics AX . It assumes that a record retrieved from the database is not updated , until it is proven to be updated by the database which means that in case of updating a record the system compares the rec Version field of the record with the actual record in the database. The rec Version field is updated each time a record is successfully updated. There are two exceptions thrown in case of a record been updated in a transaction using Optimistic Concurrency Control.


 Handling Exception in Code:





























In the above example in the Try block an exception is thrown if the user lefts any dialogue field empty or if the AccountNum already exists. This Exception is then caught in the Catch Block later in the code .

I believe it was helpful.

  

Tuesday, 6 November 2012

Dynamics Ax 2012 Security


SECURITY :


       Role based security defines the access to Microsoft Dynamics Ax 2012 application and data . It relates to the job role that an end user has with in an organization . The role includes the duties, privileges and permissions required by that role.
  
        The maintenance of roles and duties is typically undertaken by the system administrator  where as the maintenance of privileges and permissions is performed by the developer.

BASIC CONCEPTS:


 Security Roles:

          It depicts the behavior that a person in an organization can play. A Security role includes one or more duties.
   

 Duties:

       A responsibility to perform one or more tasks. A duty requires one or more privileges in order to perform that duty.

 Privileges:

         The access required to perform a duty. A privilege includes one or more permissions.
  

 Permissions:

         The level of access associated with one or more securable objects that are required to perform the function associated with an entry point.

 Designing Role Based Security:         

  1.  First of all we need to set up a new user .
  2.  The end user is assigned one or more security roles.
  3.  Security role is assigned one or more duties.
  4.  Duties require one or more privileges.
  5.  A privilege contains one or more permissions.
Have a look at this example:



According to the above diagram the Accounts Receivable Manager Role has the duties of maintaining customer master and to inquire chart of accounts for which it requires privileges (i.e) delete access to customer form display menu item and create new address action menu item But in order to know the level of access it requires permissions on that form  (i.e) Read , Update , Create , Delete. 

I believe it was helpful ..

For further reading you can refer other useful links like:
  

Dynamics Ax 2012 FactBoxes


FactBoxes:

              A FactBox is used to display the data related to the currently selected record in the list page.
  
 There are three types of  Factboxes :

1) InfoPart.
2) FormPart.
3) Cues.

  • InfoPart: 
 It is very simple to create and can display limited number of controls. It has its own data source and can also be displayed in Enterprise Portal.  

  • FormPart:                                         

             It is a link to a Form and can  have the same controls as an standard form .It is displayed in the FactBox Section , So adding too many controls can crowd the form.

  • Cues:

               It is used to display the Count of number of records related to the current record in the list page.
                           
 For Further information you can read from here:
               http://msdn.microsoft.com/en-us/library/gg847986.aspx 
                    

Friday, 12 October 2012

Full Text Index


Full Text Indexes:

           
 Full text index are very helpful in searching for words that are embedded in the midlle of string fields . This information can be used by queries to run more efficiently and bring more accurate results. This index can also be used on MEMO and EDT's .
There Can be only one Full Text Index per table.

 

How To Create a Full Text Index:

  • First we need to create a table and the table must contain string fields.
  • Set the Table group property of the table to Main.
  • Expand the table and right click on it's Full Text Index node and create new Full Text Index.
  • Drag and drop the table's string fields on the newly created Full Text Index.
Your project should look like this.


    
   

Using Full Text Index In Queries:


In order to Use Full Text index in queries we need to create a simple job like this.





Hope it was helpful to you.....






                                                                        




Tuesday, 2 October 2012

Ax 2012 Queries


Queries in AX2012


There are three types of queries in Dynamics Ax.

1.       INLINE QUERIES

2.       AOT QUERIES

3.       QUERY BUILD API

Each of them has their different usage and conditions in which they are suitable to use.

Usage of Inline Queries:

·         They are used when we require a query that isn’t reusable or is used for a specific condition or scenario.

Usage of AOT Queries:

·         They are used when we require a query that has to be reused on multiple scenarios.

     Usage Of Query Build API:

·         Mostly Used when we have to run existing AOT Queries with modification.

   

     EXAMPLE:     

                 In this Example I will Show simple jobs demonstrating a Single Query in all three Forms.

         

     Inline Query:
                           


The Image above shows a Simple Query in which there is a join between HcmBenefit & HcmBenefitPlan Tables.


     AOT Queries:

              We need to create a new Query under the Query node of the AOT.

                                     
                  
    Then to run this query we need to create a simple job as follows.


                

                                       

  Query Build API:

   Now to produce the same query with Query Build API we have to create a Job as shown below.

  
                               
    I hope It was helpful.                                    

Monday, 3 September 2012

How to Highlight or Color Records



   Highlight or Color Records:

       Today I will share something that you may find interesting. First have a look at this form.

 


      In the same CustTrans Form now the records are colored hence making that form more user friendly.

Ø  This is done simply by just overriding the displayOption method of the form dataSource.