Wednesday, 3 October 2012

EP

Good Block for EP learner :
http://www.youtube.com/watch?v=v13kASc5XKg
http://eprogrammers.blogspot.in/search/label/Ax%20Enterprise%20Portal - how to create Ep page and Lookup ..
http://www.youtube.com/watch?v=Jjhg3xIrpoE ---> How to create Wizard in EP
Main Change 2012 :
-> Whole presentaion layer out of Morphx is removed from AX and moved to VS. Adv : It gives control to over
all .Net controls and 3rd party controls.
Developer Experience :

 

hi

Architecture of EP :
1. Users who use EP
2. Browsers
3. Once log on to EP - MOSS 2007- MSoffice sharepoint Service 2007 .Windows Share point - 3.0 . diff webparts,
outer box webparts, there is no limitation on Webparts used in EP .
User controls webpart - is a web part which allow to host any standard ASP.net User control.

Key steps as developer : Morphx - Business Logic and data modeling .
create dataset,table , create classes in Morphx, VS - Create User control, Go to share point and post User
control in User control webpart.
User Control : Collection of UI Controls - like lookup, popup,Grid, form  or any standard AX controls and
third party control( silver light control )
Outerbox Credit Control - Ex demo - to show customer

Base of all these is the AX data source control - - .net Business connector - AXDatasource control - It allows
u to access all meta data and Data  in form of EPI . These EPI are consumed by AX data source control which
provides access  to data to all UI Control.
AX Datasource - We have to build our Databinding store on top of ASP.net datasource .
ie., As ASP.net have Databinding store , Data source - AXData source ctrl, DataBound- AXBoundField


Reports Webpart : Allows you to host any report built in Reporting Services.
Guiding Principle when came to EP architecture:
1. we shld have programing model which is similar to that of AX 2009 client. We dn't want steep curve for the
developer in building EP apps.  The articrafts built in AOT for AX EP, are very similar to accounting parts in
client. ex; webmenu similar to menu.
2.we have AOT -Data modeling VS - VS Ctrl, Share point - To create Web pages We want to unify all artificants
to single AOT store. Help to have single security model that can be  to client as well as EP.Since everything
sit in AOT , we can apply same security model as Client articrafts.
Advantages over X++ Based framework over ASP.net Based Framework ie., Web UI framework:
1. If you can built a functionality on Standard ASP.net web application you can develop in EP. There is no
stoping of using any controls there.
2.  Built of AJAX in to the framework itself. if you want use webpart to host our user control , we dn't want
to worry how to integrate.. We can use AJAX on EP.
3. Extend
4. Managed Code developement - We need to use X++ for UI rendering but now we are using ASP.Net for UI
rendering.
Advantages over traditional ASP.Net Solution :
=============================================
1. Data binding everything is built in framework itself .. so no need to worry in EP
2. Field group is specific to AX not ASP.Net . We can access field group in EP even. At design time it is
single field in markup and at run time it would easily explore to multiple fields .
Nodes which are specific to EP :
==============================
1. Dataset node
2. Web
   i) Web Menus
   ii) Web menu Itms
   iii) Files - Web user Controls are saved.
   iv) Page Definition node - where all share point pages are saved.
   v)  Web content >>  managed - have all user controls.
Difference b/w datasets and Form data sources is Design is missing in Datasets.


http://blogs.msdn.com/b/epblog/archive/2008/06/04/the-basics.aspx
http://channel9.msdn.com/Blogs/meysun/Microsoft-Dynamics-AX-2009--Calling-X-classes-in-Enterprise-Portal-User-Controls-in-C  ---> vedios

http://blog.rahulsharma.in/2009/06/ms-dynamics-ax-2009-ep-development-part.html


 1. How to create a page that contains a grid with AX customers :


To keep it simple I will create a data set with one form data source which will point to the CustTable.
1. Go to the AOT and locate the Data Sets node. Sample Customer Dataset in the AOT
2. Create a Data Set in the AOT and name it SampleCustomers.
3. Add a data source under Data Sources.
4. Change the name property to CustTable and set the Table property to CustTable.

By adding a data source for the CustTable the data set will retrieve customer records from the CustTable. The data set is now ready to be used in a User Control.

 VS >> New >> New Web Site  under  MyTemplates , DynamicsAXWebProject
Click  OK .  Project  is created in VS  it contains  a node called AxWebUserControl.ascx

RC  on it select View Designer, will bring up  a blank design surface  where the content  of the User Control can be designed.
Open  VS ToolBox and locate  Dynamics AX  tab
AX data source control (AxDataSource). Drag and drop it from the Toolbox onto the design surface.
The drop down list contains all the data sets defined in the AOT including the SampleCustomers data set I just created
second control that I need is the AX grid control (AxGridView). This control is a standard ASP.NET GridView control (and thus an ASP.NET data bound control) because it derives from the GridView class 
 It adds additional functionality like an improved user experience, integrated filter control, context menu and a lot more
After dropping the AxGridView control onto the User Control I will link it to the AX data source control by selecting the data source control (AxDatasource1) from the drop down list on the AxGridView's tasks pane. The grid control is now bound to the data source control and using standard ASP.NET mechanisms the AxGridView control will at runtime ask the data source control for data which will prompt the data source control to run the data set defined in the AOT.
Open the bound field designer by clicking the Edit Columns link on the AxGridView's tasks pane. In the bound field designer all the fields from the CustTable as well as Field Groups are listed in the Available Fields tree view.

The fields are grouped into different bound field types like BoundField, BoundFieldGroup, CheckBoxField, DropDownField, etc. The most common type is the BoundField and most of the fields in the CustTable are listed under that node in the tree view. The BoundField will render the data as a read-only string when the data is read-only, and in a editable text box when the data is editable. It is used by EP for most table field types in AX i.e. String, Integer, Real, Date, Time, UtcDateTime and Int64. The CheckBoxField and DropDownField types are used for Enum table fields. The way the fields are grouped in the tree view is thus determined the field types on the table - in other words it is driven by the metadata defined in the AOT.

 Side Note: An AX bound field is an ASP.NET concept that is used in the new EP framework for data binding. The AX bound fields are used to describe the fields in a data bound control. They play an important role in EP (and in ASP.NET data binding) where they besides rendering the data for the individual fields also do field level security trimming, data validation, data formatting, and a lot more. They will be covered in more depth in later blog posts.


So from the Available Fields tree view I will select the set of fields that I want to bind to on the grid. Double click on the AccountNum, Name and CreditMax. Note that the CreditMax field is a Real field type in the AOT. I also want to bind to the Enum field OneTimeCustomer, which is located under the CheckBoxField node in the tree view.
After selecting the fields in the bound field designer click OK and the grid should now render the selected fields as columns on the design surface.
Side Note: Field groups are not rendered in the design view and will appear as an empty column in the grid. Only at runtime is the field group flattened into the actual fields.
Let's rename the AxWebUserControl.ascx User Control to SampleCustomers.ascx by right-clicking on it and selecting Rename. After saving the User Control it is now complete.

But before I can add it to a page in EP I need to import the User Control to the AOT. That is required in order for it to be deployed to the web server where EP is setup. Fortunately that is very simple. The Enterprise Portal Developer Tools in Visual Studio enable this by right-clicking on the User Control in the Solution Explorer and selecting Add to AOT.
That will save the User Control in the AOT under \Web\Web Files\Web Controls and in addition it will deploy the User Control to the web server where the EP development site is deployed. 
Side Note: From this point on whenever the User Control is saved in Visual Studio the User Control will, courtesy of the EP Developer Tools, also be updated in the AOT and it will be redeployed so the changes can immediately be seen in Sharepoint when the page is refreshed. This link is reestablished when the Visual Studio project is reopened after a shut down.


Bringing it all together in Sharepoint
The final part is to create a new page in Sharepoint where the User Control will be added. This step is similar to 4.0 except that I will not add a web form web part to the page but the new Dynamics User Control Web Part. Navigate to EP and create a web part page named SampleCustomers. Once the page is created bring up the web part gallery picker by putting the page in edit mode and clicking Add a Web Part on one of the web part zones. In the gallery locate the Dynamics User Control Web Part and select it.

Modify the properties of the new Dynamics User Control Web Part and in the Managed content item drop down list locate the SampleCustomers User Control. Click OK on the web parts properties pane and exit the edit mode off the page.
The page should now render the User Control in the web part as grid of customers.



2. Add   Ranges  and  use  display/edit  methods  in AXGridView :
1.      Data set ( add ranges in init  method of data source )
QueryBuildDatasource  qdbs;
QueryBuildRange  qbrCurrencyCode;
QueryBuildRange  qbrBlocked;
QueryBuildRange  qbrOneTimeCustomer;
super();
qbds  = this.query().dataSourceTable(tablenum(CustTable));
qbrCurrencyCode = qbds.addRange(fieldnum(CustTable,Currency));
qbrCurrencyCode.value(queryValue(CompnayInfo::standardCurrency());
qbrCurrencyCode.status(RangeStatus::Open);
qbrOneTimeCustomer = qbds.addRange(fieldnum(CustTable,OneTimeCustomer));
qbrOneTimeCustomer.value(queryValue(queryValue(NoYes::No));
qbrOneTimeCustomer.status(RangeStatus::Locked);
qbrBlocked = qbds.addRange(fieldnum(CustTable,Blocked));
qbrBlocked.value(queryValue(queryValue(CustVendorBlocked::No));
qbrBlocked.status(RangeStatus::Hidden);

Now create  a Website ( using DynamicsAXWebProject  Template) – Add new item DynamicsAXUserControl  >> Add to AOT. Go to design mode of the ctrl
Add AxDataSource ( to newly create DS)
Add AxGridView Control   bind this to Data source  just added.  Now Edit Columns  , select the colulmns

Create  a Share point , Site Action>> Create >>  WebPartpage à Choose Layout Template -  Header,Left column Body , Document Library – select Enterprise Portal   , click Create.

Click  AddWebpart , Dynamics User Control Webpart. Editing  it to the new user control created.

=======================================================================
http://channel9.msdn.com/Blogs/meysun/Microsoft-Dynamics-AX-2009--Using-Record-Context-in-Enterprise-Portal


 Record Context  : (Constructing and  consuming Record Context Automatically and programmatically)  - How to build User controls in EP for ax and use record context – Ax way of passing  the currently selected record inf to the connected detail page or webpart.
                Dataset,UserControl,WebpartPage, Consuming Web parts and  add them to the page and connect them.
Add Data set, Gridview , select columns 
1.       HyperLinkField ( Header Text – CustomerId  , MenuItem -  EPCustomerInfo , DataField – Accountnum
2.       Name.


1.       AxHyperlinkBoundField  automatically generates  the link with the record context

Create  a new webpart page in EP brings  design surface on EP.  ( edit web part and add our user control ) Web part role – Provider, Managed Content item – SampleContextProvider.

2.       View link – URL with record context  constructed programmatically

Go to Source ,
< dynamics :: AxGridView ….
                <columns>
                                <asp::TemplateField>
                                                <ItemTemplate>
<asp:HyperLink ID = “ViewLink” runat  = “Server” Text = “View”/>
                                                </ItemTemplate>
                                </asp::TemplateField>

Now to Grid RowDataBound Event  ,

Need to Add Directives,
Using  Microsoft.Dynamics.Framework.Portal.UI;
Using  Microsoft.Dynamics.Framework.Data.Ax;

Protected void gvContextProvider_RowDataBound(object s,
{
                If(e.Row.RowType  ==  DataControlRowType.DataRow &&
                                                e.Row.DataItem != null)
                                {
                                                //Since we are binding  to AXDataSource control we assume that the Data item
Gets current Dataset view row which event provides  ->
                                                DataSetViewRow dataSetViewRow = (DataSetViewRow)e.Row.DataItem;
                                                //Create the AX menu item for the hyperlink  ( the page we link to )
AxUrlMenuItem  customerInfoMenuItem  = new   
AxUrlMenuItem(“EPCustomerInfo”);
//Set the context of the menu item to the data set view row table
                                                CustomerInfoMenuItem.MenuItemContext = AxTableContext.Create(
                                                    dataSetViewRow.GetDefaultTableDataKey(
                                                   dataSetViewRow.DataSetView.Metadata.RootDataSource));
// we want to remove  navigation in new window
                                                CustomerInfoMenuItem.RemoveNavigation  = true;
//Get  the hyperlink  control  in the template field
                                                HyperLink  viewLink = (HyperLink)e.Row.FindControl(“ViewLink”);
viewLink.Target = “_blank”; (// so it opens every time in new window)

3.       Uses Programmatic way of consuming record context

Create  a new User control,
Data set – to previous DS created. , AXForm control, set  data source to previously add.
Data member – CustTable_current.
Add Group control to AX form , In fields  section add the necessary fields to be displayed.

Add user control to Webpart of the same page, But set  Web part role – Provider, Managed Content item – SampleContextProvider

Now we  have both web parts on same page,
For first web part edit dropdown >> Select Connections >>  SendAxContextListTo – DynamicsUserControlWebPart[2].

4.       Consumes  Context  automatically and uses data binding to display  the record.

Need to Add Directives,
Using  Microsoft.Dynamics.Framework.Portal.UI;
Using  Microsoft.Dynamics.Framework.BusinessConnector.Adapter;

//Whenever Context changes,  in page load we call  external context change event is fired
Under  page  load,

//Add event handler for the External Contextchange event.
(AxBaseWebPart.GetWebpart(this)).ExternalContextChanged += new EventHandler<Microsoft.Dynamics.Framework.Portal.UI.AxExternalContextChangedEventArgs>  AxContextConsumer ExternalContextChanged;

Void AxContextConsumer_ExternalContextChanged(object sender,Microsoft.Dynamics.Framework.UI.AxExternal
{

                //Get  the AxTableContext from the ExternalContext passed through
                //and get  to the value of the fields
IAxaptaRecordAdapter currentRecord = (AxBaseWebPart.GetWebpart(this)).ExternalRecord;
                {
                                If(currentRecord !=null)
                                                {
                                                                lblCustomer.Text = (string)currentRecord.GetField(“Address”);
}
}


========================================================================

Create  a Simple  Task page  in EP using AX Form Control 

1. create  a DS in AOT

No comments:

Post a Comment