Skip to main content

Posts

Showing posts from 2011

Create AxTableContext from IAxaptaRecordAdapter or from a RecId

Somtimes we need to create a record context from a custom record but not based on a record from a data set. It is a bit tricky to create a menu item record context fram an IAxaptaRecordAdapter or a RecId. Here is an example // Get the recid for which record the context should be fore // where record is any record from any given table in Ax Int64 recId = record.GetField( "RecId” );                      int tableId = TableMetadata .TableNum( this .AxSession, "[TABLENAME]" );   // Create a dict table Proxy. DictTable dictTable = new Proxy. DictTable (AxSession.AxaptaAdapter, tableId); // Get the field id int fieldId_RecId = TableDataFieldMetadata .FieldNum( this .AxSession, dictTable.name(), "RecId" ); // Create the table metadata TableMetadata tblMetadata = MetadataCache .GetTableMetadata(AxSession, tableId); // Create the dictinary object Diction...

Debugging X++ code running on EP pages works in Ax 2012

I have been using Ax 2012 for some time now and i tried out the debugging of X++ code running on EP pages. I followed these steps and it worked http://msdn.microsoft.com/en-us/library/aa629010.aspx This was a big issue after Microsoft launched Windows Server 2008 with a totally new security model. I had few chats and meetings with Microsoft about this issue and Microsoft released a hot-fix soon afterwords. Even though debugging was almost not possible since you had for example to use the account that was to debug the code for the AOS. I am very glad that this issue has been solved now and this is the key factor " A member of the Microsoft Dynamics AX Debugging Users local group on Windows "

Persist filter and keep filter expanded

Many of you have problably seen these blog posts Persisting Filter conditions in EP Grid http://blogs.msdn.com/b/epblog/archive/2009/08/29/persisting-filter-conditions-in-ep-grid.aspx and Always keep the Filter section expanded in AxGridView http://community.dynamics.com/product/ax/axtechnical/b/axsolutionsmonkey/archive/2009/04/02/always-keep-the-filter-section-expanded-in-axgridview.aspx They are excelent to use togather i.e. persist the filter and keep the filter open as well I implemented two static methods in the EP class to persist the filter, then i can use oneliners to persist the filter of any dataset. Also have in mind that if the PersistState of the ASP.NET dataset is set to false the filter is not persisted. So check out that the property is set to true , it is true by default public static void packDataSet(Name _name, container _value, QueryRun _queryRun) {     SysLastValue    sysLastValue;     ; ...

DAX 2009 Enterprise Portal - Time out problem

I recently had an EP page that listed ProjTimeSheet records for approval or rejection. When the user selected >20 rows to update a timeout occured. After short time on google i found this solution http://community.dynamics.com/product/ax/f/33/p/32933/56908.aspx  and down att the bottom is the following code snippet to set the AsyncPostBackTimeout for AJAX which was causing the timeout. I applied this code to the Page_Load method of the control in question and then i could update all the rows without getting the timeout error message. protected void Page_Load( object sender, EventArgs e) {         ScriptManager scripts = ScriptManager .GetCurrent( this .Page);     if (scripts != null )     {         scripts.AsyncPostBackTimeout = 600; // 600 seconds     } }

Remove HTML code from strings

When you work for example with the presentations DAX adds some HTML comment code to the text stored in the database. This can cause the text on the web to be displayed in incorrect format. This also takes up space in the database and makes the database file grow larger. <!--AXAPTA  MarginWidth="0" MarginHeight="0" WebletName="WebLet700062029" Type="WebPageWeblet" -->TEXT There is a nice X++ function: just call Web::stripHTML( string ), which will return the string without the HTML tags

User control changes not update on the web

Somtimes it happens that just after i have created a new Dynamics Ax web site in Visual Studio and added some controls from the AOT to the project in VS, that changes done in VS are not updated in the AOT and therefore not displayed on the web. I was a bit surprised that the solution is to right-click the user control in VS and select "Add to AOT". This ofcourse gives an error since the user control exists, but this restores the connection between VS and AX. After this all changes are reflected directly in the EP page. The ways of EP develpment works in misterious ways

Sudden error "No .NET Business Connector session found"

Recently i had a strange error for some pages in the EP, they suddenly stoped working and simply gave an error "No .NET Business Connector session found". When i looked in the Event Log on the IIS machine i noticed that one of the Ax datasets was issuing a compilation error. The solution was to simply compile the whole dataset node in the AOT and restart the IIS. After that all the pages started to work fine again. Similar issue has occured when installing EP, see Dilpips blog http://daxdilip.blogspot.com/2008/05/no-net-business-connector-session-found.html

Usefull sites and blogs

Here are some usefull links to take a look att, there are tons of sites out there but i think this is a good start EP an Dynamics Ax EP on MSDN http://msdn.microsoft.com/en-US/library/aa855178(v=AX.50).aspx Solution Monkey http://blogs.msdn.com/b/solutions/ EMA Dynamics Ax Support http://blogs.msdn.com/b/emeadaxsupport/ Florian's weblog http://blogs.msdn.com/b/floditt/ Slides from Florian regarding .NET and Dynamics Ax http://www.dittgen.net/florian/webcast1.pdf .NET and C# Four Guys From Rolla http://www.4guysfromrolla.com .NET on MSDN http://msdn.microsoft.com/en-us/library/ff361664.aspx Code Project http://www.codeproject.com/ C# and Dynamics Ax http://olondono.blogspot.com/ Scott on writing .NET http://scottonwriting.net/sowblog/default.aspx

Share common C# code

One important thing in all development is to keep code redundance at a minimum. Object orientated programming helps us alot in this area. We have at least two possibilities to acomplish this for the C# code for our Enterprise Portal .NET user controls. Method one Create a user control to hold all common code and then use that control when ever we need to access the common code. This requiers us to reference the control were ever we need the code, not very neat but it works. Method two I prefer this one personally, create a control that inherits the AxBaseUserControl and place all your code in here. When ever you create a user control, change the inheritance so that the newly created control inherits you base control. By doing this we have access to all the common code that we need with simple inheritence.

External documents in EP - Version 2

In my earlier post i showed how to use the Document Library template to create a page for external documents in Enterprise Portal (EP). In this version i will show how to create a basic web page with the EP template to manage external documents. This gives the advantage of using for example the EP menus on the left hand sise of the page. This also makes it possible to have on the same page external and internal documents if that is needed in some scenarios. We start by creating a Basic Web Page , just like any other EP page Give the new page a name and select the Enterprise Portal from the Document Library drop-down box. On the page add a web part for Shared Documents Modify the web part and display the full document toolbar  And this is the result Here we get the best from both worlds, we can access EP menues and content and even have external documents and external documents management

External documents in EP - Version 1

Since the Enterprise Portal uses Share Point to display its webparts and pages it is rather easy to have external documents page along with the Enterprise Portal (EP) content. Before we start Note that these documents are stored in the Share Point database but not in Ax. So this could be used to store documents externally and get all the benefits from the document management in Share Point, such as chek-out and check-in. Enterprise Portal has as a standard document management for documents within Dynamics Ax so don't conduse those two togather. Creating an external document library The first thing we need to do is to create a new page in the EP and make sure that you use the type document library from the group Libraries Select Document Library from the list Create the document library with the desired settings and go on. When the page has been created copy the URL to use in menu item creation in Dynamics Ax. Now we have created a document l...