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

Monday, June 28, 2010

Retrieving Record Values in an Enterprise Portal Wizard/Tunnel

    
Let’s say you have a scenario in which you need to pull a field from a newly created record that was inserted into AX via an Enterprise Portal Wizard/Tunnel. This need could be useful in the event that after a record is created, you need to obtain the record’s Id, so that you can do something else which relates to the new record. In this example we will extend the code example found in the book “Microsoft Dynamics AX 2009 Programming: Getting Started” (page 304)

protected void WizardTunnel_FinishButtonClick(object sender,
WizardNavigationEventArgs e)
{
AxDataSourceView rentalTableView =
this.RentalDataSet.GetDataSourceView("RentalTable");


if (rentalTableView != null)
rentalTableView.EndEdit();


AxUrlMenuItem carRentalsMenuItem =
new AxUrlMenuItem("CarRentalList");
Response.Redirect(carRentalsMenuItem.Url.ToString());
}
To pull the value from the CarRentalId in the following modified event handler…

protected void WizardTunnel_FinishButtonClick(object sender,
WizardNavigationEventArgs e)
{
AxDataSourceView rentalTableView =
this.RentalDataSet.GetDataSourceView("RentalTable");


if (rentalTableView != null)
{


DataSetViewRow dvr = rentalTableView.DataSetView.GetCurrent();
string CarRentalId = dvr.GetFieldValue("CarRentalId").ToString();


rentalTableView.EndEdit();
}


AxUrlMenuItem carRentalsMenuItem =
new AxUrlMenuItem("CarRentalList");
Response.Redirect(carRentalsMenuItem.Url.ToString());
}
    

Thursday, June 24, 2010

Resolving one cause of the "Invalid datasource name" in Enterprise Portal

  
If you have developed a Web Control for Enterprise Portal, which contains an AxDataSource, and an AxForm, and then you attempt to include an AxLookup control you may receive the following error:

Invalid datasource name ‘[Your Data Source Name Here]’
However, you have verified that the data source name is most definitely correct and is indeed part of your Data Set. The problem may be that you have put your AxLookup inside the bounds of the AxForm control. Place your AxLookup control outside of the AxForm, and your problem will probably go away (unless of course it is being caused by another issue)
  

Wednesday, June 23, 2010

Importing AX Projects (.XPO) & Deploying Web Controls into Enterprise Portal: Resolution for Controls not showing in the “Managed content item” drop down.

       
Recently I seriously struggled for some time in exporting Web Controls in the AOT in my development environment, and importing them into the staging environment. I created a project to include all of my web controls, by adding the related web control nodes from [AOT > Web > Web Files > Web Controls]. I then imported this project into staging, and went into Enterprise Portal to setup my Web Part Page with my custom web controls in the AOT. The problem however was that when modifying my shared web part (a Dynamics User Control Web Part), the “Managed content item” drop down did not contain my custom web controls. Oddly enough, I could create a new project in Visual Studio, and select the “Add user control from AOT” option, and my custom controls were in the list. So what exactly was going on??

A veteran Axapta developer, whom I have the privilege of occasionally tapping for information if all else fails, revealed to me that Enterprise Portal does not pull its list of Web Controls from the [AOT > Web > Web Files > Web Controls] node, like Visual Studio does, but rather, in order to see your controls in the “Managed content item” drop down, you must include the references to the controls that are found in the [AOT > Web > Web Content > Managed] node. So when I added these references to my project in the development environment, exported the project, and then imported the project into staging, and then restarting both the AOS and IIS for good measure… My custom web controls finally showed up and could be used.
       

Resolving the “System.NullReferenceException: Object reference not set to an instance of an object” on a standard Enterprise Portal page

     
Recently we were running stress tests on various interfaces that came standard in Enterprise Portal. In particular, we were testing out the Purchase > Purchase requisitions interface. Everything worked until we clicked the New > New purchase requisition button. After that, things blew up and we got a really nasty error that began with the following:

An unexpected error has occurred.


Microsoft.Dynamics.Framework.BusinessConnector.Session.Exceptions.FatalSessionException: Dynamics Object Adapter Call failed. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Dynamics.Framework.Data.Ax.DataSetViewRow.GetFieldValue(DataSetViewFieldMetadata field)
at System.Web.UI.WebControls.BoundField.GetValue(Control controlContainer)
at Microsoft.Dynamics.Framework.Portal.UI.WebControls.AxBoundField.OnDataBindField(Object sender, EventArgs e)
at System.Web.UI.Control.OnDataBinding(EventArgs e)
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBindChildren()

Long story short, I eventually found the solution thanks to a post made by someone else who was having a similar issue, and double-thanks to the same person who took the time to come back and post the solution when he/she found it. This post can be seen here.

The problem was that I had recently added a new Dimension to the system. There was however one step that I did not know I had to do after adding the dimension and doing a synchronize. The missing final step was to re-compile the “Data Sets” node in the AOT. After doing this, and then restarting IIS on the Enterprise Portal Machine, the error went away, and problem was solved!
  

Thursday, June 17, 2010

What is the “Record write validation failed. DataKey” error?

        
During Enterprise Portal Development, I received this error in a Tunnel/Wizard that I put together to create a new record in a custom table. I originally googled this error when I first received it, but absolutely no results were returned. Not too long after, a little debugging revealed that the problem was that I was not supplying the value for a mandatory (Number Sequence) field.

If I come across other causes for the problem, I will append them to this blog as I find them.

 

Thursday, May 20, 2010

Enterprise Portal: Adding an AX Web Control and Resolving the “unable to load content” Error

Following the tutorial on creating a web part page for Enterprise Portal in the book “Microsoft Dynamics AX 2009 Programming: Getting Started” by Erlend Dalen (Great book by the way!) things seemed simple enough from creating a dataset in AX (page 290) to creating the web part in Visual Studio (pages 291-295). Even the first steps of creating the web part page was straight forward (296-299). However, because my development environment was in 64-bit Windows, when it came to modifying my shared web part, to use the web part that I built in Visual Studio, one additional key step was needed. At first I received the following error message:


'unable to load content [webcontrol name]. Please contact your systems administrator'

Finding Out What The Actual Problem Is

In order to get to the bottom of what was actually going on, I learned that I needed to modify my main web.config file which is located at:

C:\Inetpub\wwwroot\wss\VirtualDirectories\80

to give me a more useful message.

1) First, I needed to modify the following line that begins with:

SafeMode MaxControls=”200” CallStack=”false” …

And change the CallStack property to “true”

2) Next, I needed to modify the following line:


customErrors mode=”On” /

And change the mode property to “Off”

3) Next, I needed to modify the following line:

compilation batch="false" debug="false"

And change the debug property to "true"

4) I then saved the the web.config file
5) Restarted IIS by executing the IISRESET command in the command prompt
6) Went through the steps of creating the web part page again.
7) I then received a far more useful error, with the first line of the error telling the story:


System.Web.HttpException: The file '/_layouts/ep/[webcontrol name].ascx' does not exist.

The Missing Step

Now knowing that the problem was that my control files didn’t actually exist where SharePoint expected them, I needed to locate the exact path where these files belonged. As it turns out, after searching, the “/_layouts/ep” path is not a physical path on the machine, so I had to find its physical location some other way. How I did this was searching the hard drive for another AX web part that was in the list of webparts that I verified was able to load (so I searched for “ActivitiesListAssociations”). This led me to the physical path of:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\ep

As expected, my custom web control files were not there.

So I copied the .ascx and .ascx.cs files from my project to this path, went through the steps to create the web part page, and web part finally loaded!