Showing posts with label Enterprise Portal. Show all posts
Showing posts with label Enterprise Portal. Show all posts

March 18, 2013

Enterprise Portal development

Enterprise Portal development (AX 2009)

We Will complete this tutorial in four steps as:





Step 1 – the prerequisites
Step 2 – Understanding proxies
Step 3 – Visual Studio
Step 4 – Debugging in Visual Studio

Step 1 – the prerequisites:

Enterprise Portal must installed on the same server as Your development environment (Visual Studio). If possible, You should also consider to have EP set up on a 32 bit platform – meaning that the OS and Windows Sharepoint Services (WSS) is running in 32 bit mode.
In matters of EP development, running on 64 bit platform is the mother of all evil – examples on this will follow…
Enterpise Portal development tools must be installed. This can be done from the installation medias.
Generally the EP dev tools installs EP project- and control templates. Please note that the EP dev tools should be installed after installing Visual Studio 2008 – if not, the VS templates will most likely not be installed correctly. To ensure that the EP dev tools are successfully installed and that the Dynamics AX web project template is available from within Visual Studio, please do the following:
The Web Site project template AxWebProject.zip is installed in My Documents folder under Visual Studio 2008\Templates\ProjectTemplates\Visual Web Developer\CSharp and page and control templates AxWebpartPage.zip and AxWebUserControl.zip under Visual Studio 2008 \Templates\ItemTemplates\Visual Web Developer\CSharp.
If these files are not found under Your user profile, You will have to copy them from the user who installed the EP dev tools.
The Add-in is installed in Program Files\Microsoft Dynamics AX\50\EnterprisePortalTools and is added to the VS Add-in files path and enabled.
  1. You can check this in VS Tools->Options->Environment->Add-in/macros security, you should see Visual Studio Options dialog
    Visual Studio Options dialog
  2. In VS Tools -> Add-In Manager Dynamics AX Enterprise Portal Tools must be enabled. Visual Studio Add In manager dialog
    Visual Studio Add In manager dialog
To check if everything is installed corrected, when you create a new Web Site Project in VS 2008 C#, you should see Dynamics AX Web project template. After creating the project, in the solution explorer when you right click on app_code folder you should get Generate Proxies menu option.

Once this has been verified everything is good to go, but before firing up Visual Studio, You should check in which layer VS connects to AX. VS uses the business connector when connecting to AX. This means that You have to check that the BC is connecting to the layer of Your choice. In my case, we always use the CUS layer. By default the BC connects to AX using the USR layer. If You want to change this do the following:
  • On the server where EP is installed, click the “Start” button in Windows. Select “administrative tools” and enter the “Microsoft Dynamics AX Configuration Utility”.
  • Change the “Configuration Target” to “Business Connector”.
Select the “Developer” tab and change the “Application object layer to open” to “CUS” (or whatever You want) Remember to fill in the license code for that layer
DAX Configuration utility
DAX 2009 Configuration utility

Step 2 – Understanding proxies:

In order to being able to reference common AX types (Objects from the AOT – Classes, tables, methods and enums) AX needs to generate proxies for the objects that You want to use. These objects are defined in the AOT from Web->Web files->Static files->proxies. If You want other objects to be recognized by EP and Visual Studio, You need to edit this file manually. A guide how to do that can be found here:
http://msdn.microsoft.com/en-us/library/cc568275(v=ax.50).aspx
To deploy the proxies to EP, please do the following:
  • From the Microsoft Dynamics AX menu click Tools -> Development Tools-> Web development -> Proxies.
In the “Generate Proxies” window You will find two options for deploying the proxies
DAX Generate Proxies Dialog
DAX Generate Proxies Dialog
  • Using the first option will deploy the proxies to the EP site automatically.
  • When using the second option the proxies will be deployed to a folder location of Your choice. From here You will have to copy the new proxies toC:\inetpub\wwwroot\wss\VirtualDirectories\80\App_Code\Proxies
  • Remember to also update the proxies from within Visual studio, in order to have VS recognize any of the new objects. From within You project in VS, right click the App_Code node and select “Generate Proxies”. You could also choose to copy the manually from the folder mentioned in the previous step.





Step 3 – Visual Studio

A new user control is easily created by right clicking Your project node and selecting “Add new item”. From the “Add new item” dialog choose “Dynamics AX user control

Visual Studio Add new item dialog
In order to add the new user control to the AOT. Right click the control and select “Add to AOT”.
Once added to the AOT changes to the control will automatically be submitted to AX. Once AX recognizes a change AX will update the control automatically on the EP site. However if running in 64 bit mode, this will not work! You can work around this in two ways:
  1. From a command prompt You can run the D:\Microsoft Dynamics AX\50\Setup\AxUpdatePortal.exe command. (The file may be located elsewhere in Your environment). Running this command will deploy all web related changes to all EP sites.
    http://msdn.microsoft.com/en-us/library/dd261467(v=ax.50).aspx
  2. Running the AXUpdatePortal command may be very timeconsuming. You may find it more useful to manually copy Your usercontrol  to Your EP site. The default path for the EP site is: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\ep. You may want to consider writing a small script to help You automate this process just a little bit.

Step 4 – Debugging in Visual Studio

Ofcourse You will want to be able to debug Your  code from within Visual Studio. In order to do so, there are a few things You need to know:
  • Changes made to your usercontrols are automatically updated at the EP site when running on a 32 bit platform. If running on a 64 bit platform, You will have to update EP manually. The process for doing so is described above.
You will have to change the debugging start options. Right click Your project and select “properties->Start options”. In the start options dialog enable the “start url” radio button:
Visual Studio Debugger Start Options
Visual Studio Debugger Start Options
and fill in the complete url for the page You want to hit on startup. This page is best found by browwing the actual EP site.
In the “use custom server” fill in the base url for the EP site. This can be fetched from within AX by entering  administration->Setup->Internet->Enterprise portal->web sites

Common issues

One of the most annoying things about working with EP related development is that You may quite often experience that EP causes Visual Studio to crash
EP Tools causes VS to crash
EP Tools causes VS to crash
The only working fix that I know of, is to create a new solution/website and have Your content transferred to that website. When the problem reoccurs the procedure has to be repeated.

-Harry

September 06, 2012

How to Enable X++ debugging for Dynamics Ax 4.0 Enterprise Portal

How to Enable X++ debugging For Enterprise Portal

To enable X++ debugging in the current user session in Microsoft Dynamics AX 4.0, follow these steps:

1. On the server that is running Internet Information Services (IIS), open a console session (also known as session 0). To use Terminal Server to do this, click Start, click Run, type mstsc /console in the Open box, and then click OK. Then, start Microsoft Dynamics AX 4.0 in the Terminal Server session.

2. Set the .NET Business Connector configuration and the client configuration to enable breakpoints when you run the Business Connector. To do this, follow these steps:

 a. Click Start, click Run, type Control admintools, and then click OK.
 b. Double-click Microsoft Dynamics AX Configuration Utility.
 c. In the Configuration target list, click Business Connector (Non-interactive use only).
 d. On the Developer tab, click to select the Enable user breakpoints to debug code running in the business      connector check box and the Enable global breakpoints to debug code running in the business connector check box.
 e. Click Apply. Then, click OK.Repeat step a through step e for the local client configuration in the Configuration target list.

3.Enable debug mode. To do this, follow these steps:

 a.On the Tools menu, click Options.
 b.Click the Development tab.
 c. In the Debug mode box, click When Breakpoint.
 d. Click Apply, and then close the Options dialog box.

4.Locate the code that you want to debug. Before the code that you want to debug, type the keyword breakpoint.

5.Manually start the debugger. To do this, click Tools, point to Development tools, and then click Debugger.

6.Enable desktop interaction for the World Wide Web Publishing Service. To do this, follow these steps:
 a. Click Start, point to All Programs, point to Administrative Tools, and then click Services.
 b. Right-click World Wide Web Publishing Service, and then click Properties.
 c. Click the Log On tab.
 d. Click to select the Allow service to interact with desktop check box.
 e. Click OK to close the World Wide Web Publishing Service (Local Service) dialog box.

7. Make sure that the user who is logged on to the computer is one of the following users:

•The user who is running the Web application pool
•The user who starts a session in Microsoft Dynamics AX 4.0
•The user who set up breakpoints in Microsoft Dynamics AX 4.0


-Harry

April 14, 2012

How To Create Forms in Enterprise Portal

ABSTRACT:- This article demonstrates how to create basic forms in Enterprise Portal. Create a DataSet

1. Open Microsoft Dynamics AX.
2. Open the AOT.
3. Right-click on the Data Sets node and choose New Data Set.
4. Right-click on the newly added data set and choose Properties.
5. In the property sheet rename the new Data Set to SampleCustomers.
6. Expand SampleCustomers.
7. Right-click the Data Sources node and choose New Data Source.
8. Right-click the new Data Source and choose Properties.
9. In the property sheet set the Table property to CustTable.
10. In the property sheet set the Name property to CustTable.
11. In the property sheet set the InsertIfEmpty property to No.

  • Create a Web Project
1. Open Microsoft Visual Studio 2008.
2. Under the File menu choose New and then Web Site.
3. Choose Visual C# as the Language – note that only C# is supported.
4. Choose Dynamics AX Web Project as the template.
5. Enter SampleBasicForm as the project name.
6. Click OK when finished.
  • Create a User Control and Add it to the AOT
1. In Visual Studio add a new File under File then New File.
2. Choose Visual C# as the language.
3. Choose Dynamics AX User Control under the My Templates Section.
4. Enter SampleBasicForm.ascx as the name.
5. Click Add when finished.
6. In the Solution Explorer, right-click on the new user control, SampleBasicForm.ascx, and select Add to AOT.

  • Add a Form to Your User Control
Forms in Enterprise Portal are used to display and edit record information. They consist of three different controls, an AxDataSource, an AxForm, and an AxGroup. The AxDataSource is used to interact with data. The AxForm is a container for the form entity. The AxGroup will reference and display fields
from the data. The specific record information to display is retrieved from the external context (information passed through the URL).

1. In Visual Studio in the Solution Explorer, right-click the user control and select View Designer.
2. Locate the Microsoft Visual Studio 2008 Toolbox under View then Toolbox.
3. Find and expand the Dynamics AX section.
4. Drag-and-drop an AxDataSource onto the design.
5. Click on the arrow in the upper right-hand corner of the AxDataSource and set the DataSet Name    property to SampleCustomers. This can also be done through the properties pane.
6. Right-click on the AxDataSource and choose Properties.
7. Rename the new AxDataSource to Customers_DS by changing the (ID) property to Customers_DS.
8. Find the AxForm control in the toolbox under View and then Toolbox.
9. Drag-and-drop the AxForm onto the design.
10. Right-click on the AxForm and choose Properties.
11. Rename the AxForm’s ID to SampleCustomers by changing the (ID) property.
12. Set the DataSourceID property to Customers_DS.
13. Set the DataMember property to CustTable_Current.
14. Find the AxGroup control in the toolbox under View and then Toolbox.
15. Drag-and-drop the AxGroup onto the AxForm.
16. Right-click on the AxGroup and choose Properties.
17. In the Fields property for the AxGroup, click the … icon.
18. Add AccountNum, Name and Address from Available Fields by double-clicking or selecting each item and clicking Add Field.
19. Press OK to save.
20. Click the Save icon on the Visual Studio toolbar to save your project.

  • Testing Your User Control To Test Through Microsoft SharePoint Services
1. Navigate to your Microsoft Dynamics AX Enterprise Portal web site.
2. Click on Site Actions and select Create.
3. Click on the Web Part Page link.
4. Choose a Name, Template, and the Document Library Enterprise Portal.
5. Click the Create button.
6. If the page is not in Edit Mode, click Site Actions and select Edit.
7. In one of the web page’s sections click the Add a Web Part bar.
8. Check Dynamics User Control Web Part and select Add.
9. On the new web part, click edit and select Modify Shared Web Part.
10. Set the Managed content item property to your user control, SampleBasicForm.
11. Click OK.
12. Under the Site Actions menu click the link Exit Edit Mode.
13. Minimize the web browser.
14. Locate and open the web.config file for the SharePoint site. (ex: C:\Inetpub\wwwroot\wss\VirtualDirectories\80)
15. Locate the compilation section and set the debug property to true


16. Open your Microsoft Visual Studio 2008 SampleBasicForm project.
17. From the menu choose Debug and select Attach to Process.
18. Select the w3wp.exe process for the SharePoint site and click Attach.
19. In Visual Studio’s Solution Explorer right-click your control and choose View Code.
20. Add breakpoints to the code where needed.
21. Maximize the open web browser and refresh the SharePoint site.
22. When finished debugging, set the debug attribute in the web.config file back to false.

  • To Test Through Microsoft Visual Studio 2008
1. In Visual Studio in the Solution Explorer, right-click the project node and select Import Style Sheets.
2. In the Solution Explorer, right-click the AxWebPartPage.aspx page and select View Designer.
3. In the design under Body, locate dynamics:AxUserControlWebPart1. It is the second box containing Untitled under the Body.
4. Right-click dynamics:AxUserControlWebPart1 and choose Properties.
5. Set the Dynamics AX Managed Web Content Item property to your user control, SampleBasicForm.
6. Save your control.
7. In the Solution Explorer right-click your SampleBasicForm control and choose View Code.
8. Add breakpoints to the code where needed.
9. In the Solution Explorer, click on the AxWebPartPage.aspx so it is selected.
10. Click the green arrow on the toolbar to build and run the solution.


-Harry