Tag Archives: Ax 2009

SystemSequences Update


If you ever get a error where the RecId being inserted into the table already exists then the SystemSequences table is to be blamed for this

In some of my previous blog posts, i update the system sequence table’s NextVal record, which determines the RecId to be given. However, this is tricky.

  1. Update in SQL
    • Stop the AOS
    • Update the NextVal recod in the SystemSequences Table
    • Start the AOS
  2. Write a job
static void SetNextRecId(Args _args)
{
    SystemSequences seq;
    ttsBegin;
    select firstonly forupdate crosscompany seq
        where seq.tabId == 123456; // use the table id here or tablenum()
    seq.skipTTSCheck(true);
    seq.skipDatabaseLog(true);
    seq.selectForUpdate(true);
    seq.nextVal = 5637123456 + 1; // enter the last recId for the table
    seq.update();
    ttsCommit;
}

You may need to run this job and restart the AX client only if the just the above doesn’t work

static void sab_recIdSequenceFix(Args _args)
{
    SystemSequence systemSequence = new systemSequence();
    Tableid tableId = 123456; // use the table id or tablenum() here

    systemSequence.suspendRecIds(tableId);
    systemSequence.suspendTransIds(tableId);
    systemSequence.flushValues(tableId);
    systemSequence.removeRecIdSuspension(tableId);
    systemSequence.removeTransIdSuspension(tableId);
}
Advertisements

Iterate through AOT tree


I came across this piece of code which was required to check the AOT elements for certain things.
This iteration should work fine as long as all the developments done show up in your session.
The best way is to restart the AOS and run it to make sure the utilElements have all new objects

UtilElements e;
UtilEntryLevel utilLevel = global::currentAOLayer();
TreeNode treeNode;
;
while select e
where e.utilLevel == utilLevel
&& !(e.recordType == 37 //SharedProjects
|| e.recordType == 78) //WebListDef
{
//treeNode = xUtilElements::getNodeInTree(e);
treeNode = xUtilElements::getNodeInTree(xUtilElements::parentElement(e));
//DO SOMETHING WITH THE treeNode HERE.
}

Ax bug in X++ join statement – Compile error


So i have found a bug in Ax relating to join statement.
Based on the Image, you can see that i am joining 2 tables, and setting a where statement for the first one to a tableId
All 3 should give me the same result.
However i get a compile error in the 3rd statement. It involves around checking the RefTableId field of Table 2, and comparing it to a tablenum method.

Ax X++ select statement join bug
Ax X++ select statement join bug

The 1st method uses the same functions, but all the where clauses are after the join statements. This however can get ugly (unreadable) when there are a lot of where clauses as you would like to have them grouped up.
//Join scenario 1
select firstonly table2
join table1
where table2.MyRefTableId == tablenum(Table2)
&& table1.SomeId == "ID00001";

The 2nd method of select statements groups the where clauses nicely. However to do that, I have to use the tablename2Id function instead.
//Join scenario 2
select firstonly table2
where table2.MyRefTableId == global::tableName2Id(tablestr(Table2))
join table1
where table1.SomeId == "ID00001";


The 3rd method is the culprit, for which i have no explanation at the moment. Anyone want to shed some light on this?
//Join scenario 3
select firstonly table2
where table2.MyRefTableId == tablenum(Table2)
join table1
where table1.SomeId == "ID00001";

This gives me a “Syntax error”

Show batch class in task list


Sometimes running a batch job may depend on another one completing before it runs. To ensure that can happen, and to set it up involves some development work.

To add a batch job to an existing batch task list, lets first set up a batch job

imageFor this example i have created a batch job, and added the class InventTransferMultiPick (Transfer order – Picking list) to the list.

I have created my own batch job called MyBatchClass. This class needs to run only after the InventTransferMultiPick class has finished executing.

When I try to insert another record into the Batch tasks, it does not show this class there. For reasons, there is a setting required in the class called canGoBatchJournal. This method by default returns false, and needs to be explicitly overridden and set to true.

protected boolean canGoBatchJournal()
{
    /*
    boolean ret;
    ret = super();
    return ret;*/
    return true;
}

This then allows the batch to be added as a task manually:

image

You can set the parameters:

image

And set a condition in the “Has condition” group:

image

Ax Reserved keywords for fields


image

The table defined has 3 fields and works as expected.

However if the name of the field is changed to a SQL reserved e.g. “Exit”, you will get the following error when opening the table

image

image

Errors are:

Cannot select a record in Table1 (Table1).
The SQL database has issued an error.

SQL error description: [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near the keyword ‘EXIT’.

SQL statement: SELECT A.INTFIELD,A.NOYES,A.EXIT,A.RECVERSION,A.RECID FROM TABLE1 A WHERE (DATAAREAID=?) ORDER BY A.DATAAREAID,A.RECID OPTION(FAST 1)

 

For a full list of reserved words please refer to the version of SQL you are using

SQL Server 2000

SQL Server 2005

SQL Server 2008 R2

Dynamics Ax 2009 – Enterprise portal – Page deployment


 

A page in Enterprise portal is defined by 2 objects in Ax 2009

1. Web menu item URL

Path AOT –> Web –> Web Menu Items –> URLs

image

2. Page definition

Path AOT –> Web –> Static Files –> Page definitions

image

Every time a Page is changed (added / removed user controls / web parts) the page definition needs to be updated.

To do this locate the URL of the web page in the AOT

and right click –> Import

image

After importing the file, look at the page definition for the corresponding URL. It will not have an object in the current working Layer.

image

 

Deploying specific EP pages:

Right click on the page definition –> deploy page

image

This deploys the page and a message is shown

This deployment method is not supported for 64 bit machines, and some of the 64 bit machine I have worked with give issues and may not deploy. The only way to deploy it is by using the AxUpdatePortal.exe

NOTE: AxUpdatePortal.exe will redeploy the entire enterprise portal

MSDN Enterprise portal blog : http://blogs.msdn.com/b/epblog/