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 .