Tuesday, December 1, 2009

Displaying the text format of an AX Query

Question: How can you print the query associated with an AX Query?

Answer:
static void printQuery(Args _args)
{
Query query = new Query(querystr(MyQuery));
;
info(query.dataSourceNo(1).toString());
}

Monday, July 20, 2009

date in american standard format

Question: How can I get date in american standard format.

Answer: I have created a class that can be used to get the date in american standard format. Also there is a global method date2StrXpp that does exactly the same.

THe project can be downloaded here.

Friday, July 17, 2009

Assiging a lookup method to a control

Question: I want to add a runtime control and override a lookup method of it.
Answer: I have created a tutorial on form that can be used for this purpose. The form adds a control at run time and override the lookup method of it at runtime.

The form can be downloaded from here.

A form to display container values

Many times during debugging of container objects we normally have to view the current object list contained in the container. Normally we do it using debugger. The linked dynamics ax project will help you analyze the state of container by displaying all the container values in a form. The project contains a class and a job to use this class.
Click here to download the project.

Invoking Method on run time

Question: Can I invoke a table method on run time.
Answer: Yes this can be done using dictionary classes. Dictionary classes exposes the reflection functionlaity in Dynamics AX.

static void invokeMethodOnRunTime(Args _args){
DictTable dictTable = new DictTable(tablenum(CustTable)); CustTable custTable;
//Check if class/table has method
if(tableHasStaticMethod(dictTable, identifierstr('find'))) { custTable = dictTable.callStatic(tableStaticMethodStr(CustTable, Find), '4000'); info(custTable.name()); }
}

Wednesday, July 15, 2009

X++ call stack

Question: How Can I get the curent call stack in dynamics ax.

Answer: The method xSession::xppCallStack() returns the current call stack as a container.

Tuesday, July 14, 2009

Inside Dynamics AX 2009

Inside Dynamics AX 2009 is available now and can be bought from Amazon. The book can be found here.

From the site
"
Take an inside look at Microsoft Dynamics AX 2009 and exploit that in-depth, architectural perspective to more effectively customize and extend your enterprise solutions. The authors members of the Microsoft product team create a real-world context for essential concepts, and expertly illustrate how modules interrelate and interact. They offer practical, scenario-based guidance and troubleshooting advice on topics ranging from business intelligence and workflow to integration, reporting, and performance tuning. The book also provides extensive cross-references to additional reference and system documentation. "

Friday, July 10, 2009

trimString method in X++

public static str trimString(str _str, container _trimStr = [" "]){
int counter;
str lTrim = _str;
str rTrim;
//LTrim
for(counter = strlen(_str); counter >= 1 ; counter--)
{
if(confind(_trimStr, strdel(lTrim, 1, counter - 1))) {
lTrim = strdel(lTrim, counter, strlen(lTrim));
}
else
{
break;
}
}

//RTrim
rTrim = lTrim;
for(counter = 1; counter <= strLen(lTrim) ; counter++)
{
if(confind(_trimStr, strdel(rTrim, 2, strlen(rTrim)))) {
rTrim = strdel(rTrim, 1, 1);
}
else
{
break;
}
}
return rTrim;
}

Usage: info("trimString( "0000000000789798798.0000000", ["0", "."] ) -> " + trimString("0000000000789798798.0000000", ["0", "."] ) );

Monday, May 18, 2009

MS Dynamics AX 2009 Benchmark tool

Microsoft performance team have created a benchmark tool to carter the performance of specific objects in dynamics ax 2009. The tool can be found at
http://benchmarktoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24874

Sunday, January 11, 2009

Getting a row count from datasource

Query: How to get the total row count from form datasource.

Answer: use datasource.numberOfRowsLoaded()