Working with numbersequences – Keep In Mind
February 17, 2010
No comment
When you are using a Number Sequence, keep in mind that a Continuous Number Sequence is slower than a non-continuous. The reason is that the system creates a record in the table NumberSequenceList (with the status Active) and cleans it up later during TTSCOMMIT.
Performance tip: You can improve the performance of a process that creates many numbers of one Number Sequence by using number pre-allocation. This loads a set of numbers into the memory and provides faster access. You can do this by using the NumberSeqGlobal, witch means that once it is instantiated, it is available until the session is closed. This function is only available for non-continuous Number Sequences. The numbers can only be retrieved from the cache by calling the getNumInternal() method in the NumberSeq_Fast class.
Working with numbersequences – New Module
February 16, 2010
No comment
In a previous post I explained how to create a new Number Sequence in a existing module (Working with numbersequences – new NumberSequence). In this post I will explain how you can create a new Number Sequence-module.
I will create a new module called TEST (lack of inspiration).
Step-By-Step: (more…)
Placement of code
February 16, 2010
No comment
When you are programming, you have to think about where placing you’re code. Always try to place you’re code nearest to the source so it can be manipulated easily. For instance code that manipulates tables should be placed in that tables methods.
Best Practice: Try to minimize the x++ code in forms for the following reasons:
- Forms do not support inheritance. You cannot share logic implemented in a form with other application objects.
- The X++ code implemented in forms is always executed on the client. This means that you cannot tune an application by specifying where to execute the code.
Maximum value RecId
February 15, 2010
No comment
Did you ever wonder what the maximum value of a RecId was?
In Ax3.0 it is pritty simple. You know that the RecId was a int value and with the function ‘maxInt()’, you get the value.
In Ax4.0 and higher, the RecId is changed from a regular int to in64. There is no such function as ‘maxInt64()’ so you cant use this. In the ‘Global’, I found a method called ‘maxRecId()’.
So you just call this method and you will see that the maximum value of a RecId is 9223372036854775807 (I hope I didn’t mistype) or 2^63-1.
Moving DB-objects to other layers … without losing data
February 14, 2010
No comment
Most of us have already been confronted with the problem of tables being inserted in the wrong layer, and when they already contain data it is very difficult to transfer these objects to the correct layer without losing data.
I found the following article on Axaptapedia that helps you with this issue: http://www.axaptapedia.com/Move_DB_objects_to_another_layer
Line Number
February 13, 2010
No comment
When you want to create a table were you want to remain the position of the records you create (like the lineNum field on the SalesLine), you just need to define a field on your new table as a ‘CounterField‘.
Step-by-step: (more…)
Ax2009 different development licenses
January 28, 2010
1 comment
When you want to modify objects in Ax, you have to buy a development license. They are divided in four.
- Base Package
This license gives you access for creating/modifying reports/jobs/queries - MorphX
This license gives you access tot the Data Dictionary node where tables/Fields/enums/Extended Data Types are maintained. The ability to create forms requires the MorphX security package. - Web MorphX
In addition you can modify Web forms. - X++
Gives you access to all classes and a development code for the customer (CUS-) layer.
I hope that this gives you a clearer view to the different kind of licenses and witch one you need to have.
(Source: Course AX 2009 – DEV I)
XML parser namespace error
September 9, 2009
1 comment
Today I tried to create the following XML-structure in Ax:
1 2 | <?xml version="1.0" encoding="UTF-8"?> <personen xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Personeel.xsd"> |
I wrote the following to do so:
1 2 3 4 | xmlDoc = WGKFunctions::createXMLDocumentWithDeclaration(#version, #encoding, #standalone); root = xmlDoc.createElement(this.rootNode()); ... root.setAttribute("xsi:noNamespaceSchemaLocation", "Personeel.xsd"); |
But I got the following result:
1 2 | <?xml version="1.0" encoding="UTF-8"?> <personen xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="Personeel.xsd"> |
As you see the ‘xsi:noNamespaceSchemaLocation‘ is replaced by ‘noNamespaceSchemaLocation‘.
After some research, I found the following link: http://blogs.msdn.com/emeadaxsupport/archive/2009/06/12/xml-parser-namespace-error.aspx
You are using Microsoft Dynamics AX to create an XML Document. The code you are using to create the XML file was created for the previous version of the product and is now upgraded to Microsoft Dynamics AX 4.0 SP1.
Using the method
setAttribute(‘namespaceprefix:attribname’,'attribvalue’);
does not add the “namespaceprefix” to the final XML node.The attribute name in the final XML node will be added without namespaceprefix:
<node attribname="attribvalue" />
This is because the XML Framework was changed starting from Dynamics AX 4.0 and offers now a method that takes care about namespaces and prefixes itself.So the solution is to use the following method instead:
setAttribute2(‘attribname’,'namespace’,'attribvalue’);
Please note that the “namespace” – not the “namespace prefix” has to be entered as second parameter. The XML Framework will resolve the namespace automatically to the correct namespace prefix and add it to the final XML node:<node namespaceprefix:attribname=”attribvalue” />
So I modified my code to:
1 | root.setAttribute2("noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "Personeel.xsd"); |
and the correct XML was generated.
Internal Error Number 25 in script occurs
August 12, 2009
1 comment
When you modify the info.reportsendmail() in Ax2009 so it won’t send mails trough SysINetMail, but trough the SysMailer you could get the following error: ‘Internal Error Number 25 in script’. The same error occures when you try to post an invoice to a e-mail message.
There is a hotfix for Microsoft Dynamics Ax 2009 SP1 (KB973902) and Microsoft Dynamics Ax 4.0 SP2 (KB948130)
NOTE: This hotfix won’t fix the following: You assign different value-types to a Any-type. In this case you still get the ‘Internal error 25 in script’.
Select a record from a table when you only have the tableId
July 16, 2009
1 comment
The following code can provide you a generic way to update a table when you only have the tableId.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public Common findRecord(TableId _tableId, RecId _recId, Boolean _forUpdate = false) { Common common; DictTable dictTable; ; dictTable = new DictTable(_tableId); common = dictTable.makeRecord(); common.selectForUpdate(_forUpdate); select common where common.RecId == _recId; return common; } |
If you want, you can even update fields in this common record. You can Access/edit these fields by using their Name or FieldNum. The method below will update a specific field in a table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public void updateValue(TableId _tableId, RecId _recId, str _field, AnyType _value) { Common common; Int fieldId; ; ttsbegin; common = findRecord(_tableId, _recId, true); fieldId = fieldname2id(_tableId,_field); if (fieldId && _value) { common.(fieldId) = _value; common.update(); } ttscommit; } |




