Thursday, October 22, 2009

Adding Array Field Range on QueryBuildDataSource

At some point in your miserable life, you will need to add a range to a QueryBuildDataSource to filter on an array field such as dimension.

 

Here is an example of a code to do it

 

public client static void lookupValidParentProj(FormStringControl ctrl)

{

    Query                query          =  new Query();

    QueryBuildDataSource queryBuildDataSource;

    ;

 

    queryBuildDataSource = query.addDataSource(tablenum(ProjTable));

     //this is how to add a normal range

    queryBuildDataSource.addRange(fieldnum(ProjTable, Template)).value(queryValue(NoYes::Yes));

    //this is how to add an a range on a particular array field. In this instance, the third field in the array

    queryBuildDataSource.addRange(FieldId2Ext(FieldNum(SalesLine, Dimension),3)).value(queryValue(SysQueryRangeUtil::currentEmplDepartment()));

 

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();

}

 

Thursday, October 15, 2009

Code Sample: Building a List type and displaying it

This is just a piece of code i want to remember so here it is. If you want to retrieve a list of data from somewhere and then display it, you can use this code. It also has example on how to use a container.

 

//this code can be on a table

static List getListOfWIPForCust(CustAccount   _custAccount)

{

    AxmWIPLookup    wipTotals;

    container       cont;

    List            list = new List(Types::Container);       //list will hold a container type

    ;

 

    if (_custAccount)

    {

        while select wipTotals

        where

               wipTotals.CustAccount == _custAccount

            && wipTotals.WIPTotal

        {

            cont = conins(cont,1,wipTotals.ProjId);                      //load the data in the container, column 1

            cont = conins(cont,2,wipTotals.WIPTotal);                //column 2

            list.addEnd(cont);                                                                //save it in the container

        }

    }

    return list;

}

 

//this code can be anywhere you want to call up that list

boolean closeClientValidated()

{

    AxmProjTableTotals  wipTotals;

    ProjId              projId;

    List                wipList;

    ListEnumerator      wipListIterator;

    container           cont;

    Amount              wipAmount;

    ;

 

    ret = true;

 

    if (CustTable.openBalanceMST())

        ret = false;

 

    //check WIP total

    wipList = AxmProjTableTotals::listOfProjWithWIP(CustTable.AccountNum); //load the list by calling the code above

    wipListIterator = wipList.getEnumerator(); //use this to traverse through the list

 

    if (!wipList.empty())

    {

        infolog.add(Exception::Info, "Projects with WIP for Customer " + CustTable.AccountNum);

        while (wipListIterator.moveNext()) //traverse through the list

        {

            cont = wipListIterator.current(); //load the current list dataset into a container

            projId = conpeek(cont,1);                //grab the first column data

            wipAmount = conpeek(cont,2);    //grab the second column data

            infolog.add(Exception::Info, "Project Code: " + projId + " WIP Total: " + num2str(wipAmount,10,2,1,2));

        }

    }

 

    return ret;

}

Wednesday, October 14, 2009

Finding out if a table's row has changed before updating

When putting code in the update method of a table, you want to find out whether the field you are updating has actually changed. This code can be found under the CustTable\update method.

 

It uses the recVersion to figure out if the record has changed.

 

void update(boolean _updateSmmBusRelTable = true, boolean _updateParty = true)

{

    CustTable this_Orig = this.orig();

    recVersion rv = this_Orig.RecVersion;

    ;

.

.

.

    if(this.RecVersion != rv && this_Orig.Name != this.Name)

    {

                //do your thang!

    }

.

.

.

 

}

Sunday, October 11, 2009

Not enough rights to use table 'Signature log' (SIGSignatureLog).


ERROR: “Not enough rights to use table 'Signature log' (SIGSignatureLog).”

SOLUTION: After installing AX5 SP1, it creates a new configuration key which it leaves unticked. go into Administration > Setup > System > Confiugration and tick the Electronic Signature tick box

Wednesday, October 7, 2009

Using value from methods for Filters



A neat (new?) AX functionality is to be able to use dynamic code to filter forms. For example, you can use a piece of code that returns a user’s current department and use it for your filter.




A few things must be done.


1. You can only use methods that are in SysQueryRangeUtil class (you can create your own in this class)


2. The method must be set to public static


3. When referencing the method in the filter screen, wrap it in parenthesis



A good example on how this is used is the query called smmContacts_MyContacts where the MainResponsible range value is ((Mainresponsible == currentEmployeeId()) && (Mainresponsible != ""))



Enjoy!

Wednesday, September 2, 2009

CCADOConnection Tutorial

This tutorial is helpful if you want to update another database from Dynamics AX

 

 

static void CCADO_Tutorial(Args _args)

{

    CCADOConnection     conn;

    CCADORecordSet      rst;

    CCADOCommand        cmd;

    str                 connStr, sqlStr;

    ;

 

    conn = new CCADOConnection();

    cmd = new CCADOCommand();

   

    connStr = strFmt('Provider=SQLOLEDB.1;Persist Security Info=False;User ID=%1;Password=%2;Initial Catalog=%3;Data Source=%4'

            , 'sa'  //username

            , ''  //pwd

            , 'TestDB'  //database

            , 'TESTSERVER' //server

            );

 

    conn.open(connStr);

 

    cmd.activeConnection(conn);

 

    sqlStr = "UPDATE EMPLTABLE SET EMPLID = N'NewEmplId' WHERE (EMPLID = N'OldEmplId')";

 

    cmd.commandText(sqlStr);

    cmd.execute();

 

}

Tuesday, September 1, 2009

Installing AX 2009 COM Business Connector

For those of you who need to keep using the COM Business Connector (as opposed to the new way, .NET Business Connector), AX still allows you to install this on this version. The preceding versions will no longer support COM.

To install:

{setup folder}\Setup.exe HideUI=1 AcceptLicenseTerms=1 InstallComBusinessConnector=1

Make sure that you put “AcceptLicenseTerms” not “AcceptLicense” as some code floating around suggests. Also wait a few minutes as the setup runs invisibly.

Then go to

C:\Program Files\Microsoft Dynamics AX\50\Client\Bin

Where you will find AxCom.dll (20/05/2008 2:33PM)

Oh, and don't forget to register your new dll by going to the command prompt and typing:

regsvr32 "C:\program files\microsoft dynamics ax\50\client\bin\axcom.dll"


Enjoy!

Thursday, August 27, 2009

Dynamics AX 2009 Upgrade: Synchronize Won't Synchronize






I am upgrading from Axapta 3.0 to Dynamics AX 2009. One problem I encountered (among the many) was that i was at the stage where i have done everything before the Synchronize stage. All ticks were green. All issues resolved.





But when i click on the Synchronize option, nothing happens! I try to synchronize by using the Right Click on the Database and Synchronize, however nothing i do will make that arrow turn into a tick box.





After two days of going crazy, i am proud to share with you how i got over this problem.





I debugged the code and got to the upgrade class of \Classes\xUtilIdElements\checkDuplicateNamesWithDifferentId, and lo and behold, the process errors in this section as it is detecting duplicate Indexes on the same table, with the same Index Name, but on different layers.





HOWEVER, the code does not throw an error. Or if it does, it’s nowhere i can see it. It just exits the class and pretends that nothing happens.





So. Solution:





1. Go to \Classes\xUtilIdElements\checkDuplicateNamesWithDifferentId



2. Debug on line 59, or where it says.. ok = checkFailed(strfmt(“SYS... etc



3. On the Locals watch pane, you can determine which Index/Table/Field is the problem, and the TableId it is from (Column Name is ParentId)



4. Go to that table and delete the offending item.





I hope my two days worth of AX upgrade nightmare is somehow helpful to you


Tuesday, August 25, 2009

If I had a dollar everytime someone says that

Public Currency Dollar(String _someoneSays)

{

                If (_someoneSays == “That”)

{

                                X++;

                                infoLog::add(“I’m a rich man!”,Exception::Info);

                }

                Return x;

}

Thursday, August 20, 2009

Enterprise Portal Development Overview

A link to Enterprise Portal Development... official propaganda

 

http://msdn.microsoft.com/en-us/library/cc618471.aspx

 

Long live the geek!

Web Development within AX will be discontinued

What does this mean?

 

Currently, to create Enterprise Portal web forms/reports, you can either use:

·         Visual Studio or

·          Dynamics AX itself (in the Application Object Tree).

 

AX 2009 still has the ability to create web forms/reports from the AOT, but in subsequent versions, this functionality will be dropped and any web forms/reports have to be created through Visual Studio only.

 

Yet again, Microsoft has “pulled the rug” from under us. I actually liked the web components in Dynamics AX. They make sense to me!

 

The X++ based Web UI Framework in Enterprise Portal will be Discontinued in Future Releases of Microsoft Dynamics AX

Last Modified 20/08/2009
Posted 19/08/2009

Effective with general availability of the next version of Microsoft Dynamics AX, Microsoft will discontinue the X++ based Web User Interface in Enterprise Portal. The current release, Microsoft Dynamics AX 2009, is the last that will include the X++ based Web User Interface. In future versions, only the Enterprise Portal ASP.NET Web User Interface Framework will be included.

Background

The Enterprise Portal X++ Web User Interface Framework is a development and runtime component of Enterprise Portal for building and rendering the Web user interface.

 

The Enterprise Portal X++ Web User Interface Framework first shipped with Navision-Damgaard Axapta 2.5.  It includes a set of nodes in the AOT, such as Web Forms, Web Reports, and Weblets, for defining the Web user interface components. It also includes a set of X++ kernel classes for reading and generating HTML from these elements and renders them as Web pages. In addition, it includes a set of Microsoft Dynamics AX Web Parts (Web Forms Web Part, Web Reports Web Part, Web Menu Web Part, and the Generic Web Part) and a set of out-of-the box application pages in Enterprise Portal that use these Web Parts. 

 

With Microsoft Dynamics AX 2009, a new Web User Interface Framework based on ASP.NET, with managed APIs, Visual Studio-based development tools, and out-of-the-box application pages in Enterprise Portal built with this new Web User Interface Framework. For backward compatibility, the X++ Web User Interface Framework shipped along with the new ASP.NET Web User Interface Framework in Microsoft Dynamics AX 2009.

 

Since Microsoft Dynamics AX 2009 contains no dependencies on the Enterprise Portal X++ Web User Interface Framework, and future investment is focused on technologies built on the ASP.NET Framework-based Web User Interface, the Enterprise Portal X++ Web User Interface Framework will not ship in future Microsoft Dynamics AX releases.

 

Source: https://mbs.microsoft.com/partnersource/newsevents/news/newsgeneral/ax_epuiframework.htm

 

Wednesday, August 19, 2009

Microsoft Dynamics AX 4.0 data model overview

Thanks to Kashperuk  Ivan, who's website the document resides in, and Microsoft, who's taking over the world one mod at a time; here is a great document for us AX developers. Does anyone have the AX5 version?

 


Download AX40datamodel.doc (4.41 Mb)

 

Integrating Microsoft Axapta Using the Axapta Business Connector and Visual Basic .NET

Dynamics AX allows integration through the Business Connector .NET. i will have to experiment with this some time soon. right now i am using the COM connector, which i believe, will not be supported in next releases of AX. just another example of microsoft giving you something, then taking it away from under you. NOTE TO SELF: it's called progress. REPLY TO SELF: shutup!

http://msdn.microsoft.com/en-us/library/aa659581.aspx