Monday, April 20, 2015

Error executing code: Insufficient memory to run script. (objects with large buffer ex: xml reponse streams)

​If you see the error "Error executing code: Insufficient memory to run script"
This means that an object/variable within AX is trying to load something into a variable that exceeds the max buffer size for a variable.



When you see this error you have 2 options to fix the issue. 1. reprogram the large object to only load sections at a time. However the bad part about this is you cant just load the large objects in chunks and then combine them into 1  because when you combine them they also can not exceed the max limit. So you would need to grab part 1/4 and display/process. Then dispose of the object and get part 2/4 then dispose and get part 3/4 if you wanted to view 1/4 then you would need to dispose of 3/4 then reload part 1/4.



However you also have option 2 which is you can up the maxbuffersize for variables. This is done via the ax config file (.axc files) that the client loads. This should not be confused with the buffer size set on an AOS server that is normally 48KB. By default AX is set to allow 4mb for this variable buffer size property however in some instances doing the "partial load" doesn't make sense so you need to bump it. For instance when returning large XML data response streams you may need to up this so you can read the response in and then parse it.



If you wish to up the size of the maxbuffersize for variables within X++ the setting that needs to be added to the config file is

maxbuffersize,Text,125



where 125 is the size in MB of the new max buffer size. You can make it 0 which will allow it to be unlimited however that is highly not recommend.

You can also add the change via the registry however in 2012 R2 I did not have much luck getting the client to respect it.
 
Client Registry
Key name: [HKCU\Software\Microsoft\Dynamics\6.0\Configuration\]
Value name: maxbuffersize
Value type: REG_SZ
Value: 125

Monday, April 13, 2015

Cannot create a record in tablename. The record already exists. / Get new recid for a table

I've seen this error a couple times within the past week after we migrated our data from PROD into DEV

"Cannot create a record in <table description> (<table name>). The record already exists."

What I was finding is the index was ok and everything was unique but for some odd reason we kept getting this error, even though I did a search on the data that was being inserted and it did not exist like the system was telling us.

What I figured out is sometimes the recid count gets messed up with transferring data and you need to reset it to a value greater than the max rec id of the current table. Here are the steps to fix it.

1. Create a Job to get the table id of the table having problems inserting data

static void GetTableIdFromNameJob(Args _args)
{
    info(strFmt("%1", tableName2id("<table name>")));
}

2. In sql mgt studio

select max(recid) from <table name from step 1>

3. In sql mgt studio
Edit table SYSTEMSEQUENCES
Select the record where tabid = '<table id from info box in step 1>
Take the max id from step 2 and add 100 to it to be safe and update the field  'nextval' from systemsequences on the tableid you have selected.

4. Restart AOS (the changes will not take affect until you restart the AOS)


Tuesday, April 7, 2015

AX client crashes whenever you check out a label file that is in version control/TFS (Dynamics AX 2012 R2)

I ran across something funky today where whenever we tried to check out or modify a label file it would crash the AX Client.

The following is present within the event viewer logs

 Application: Ax32.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at Microsoft.Dynamics.Kernel.Client.ActionPaneInterop.ClickEventHelper.Clicked(System.Object, System.EventArgs)
   at Microsoft.Dynamics.Framework.UI.WinForms.Controls.ActionItem.OnButtonClick()
   at Microsoft.Dynamics.Framework.UI.WinForms.Controls.ActionButton.OnMouseUp(System.Windows.Forms.MouseEventArgs)
   at System.Windows.Forms.Control.WmMouseUp(System.Windows.Forms.Message ByRef, System.Windows.Forms.MouseButtons, Int32)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
   at <Module>._wWinMainCRTStartup()


It appears there is a KB/Hot fix for this issue listed under
KB 2902776, Bug Id 773311: Access violations when synchronizing, checking in or checking out with TFS


It will have you modify the following objects
\Class\SysLabelFile\ & \tables\SysVersionControlSynchronizeLog

Take a look within Lifecycle services for the official code changes on these objects. Its a pretty quick fix though.