AddThis

Monday, March 22, 2021

How to lookup ENUM values through SQL

SQL Statement:

select t1.NAME,t2.ENUMID,t2.ENUMVALUE,t2.NAME EnumValueName from ENUMIDTABLE t1
inner join ENUMVALUETABLE t2 on t1.ID=t2.ENUMID
where t1.NAME='WHSWorkType'

Results:



Wednesday, June 26, 2019

AX2012 axutil.exe commands to Import, Export, Delete Models

AX2012 axutil.exe commands to Import, Export, Delete Models:
creating the Model in the Layer:
AxUtil.exe create /model:"TestModel" /Layer:CUS

exporting the model to file:
AxUtil.exe export /model:”TestModel” /file:C:\AX\TestModel.axmodel

importing the model from file:
AxUtil.exe import /file:C:\AX\TestModel.axmodel

delete the model: 
AxUtil.exe delete /model:”TestModel”

delete the layer:
AxUtil.exe delete /layer:ISV

if you have multiple instances running:
delete the layer from the database and AXserver.
Axutil delete /layer:ISV /db:<database> /s:<server>

Friday, February 1, 2019

AX 2012 Client Session Types

  • User – This corresponds to the rich client (Ax32.exe) i.e. the type User is the real user logged in into the AX client.

  • Worker – This session type is overloaded to represent different session types but it is primarily seen in the context of the Business Connector. When BC is used to connect to an AOS, 2 sessions are initially created.  The Worker session type corresponds to the main session that is used to represent the BC process. Each time a Logon related method is called a Business Connector session is created, when LogOff is called then the Business Connector session type is removed from the AOS memory and in the database. But the Worker session will be present as long as the BC process is active. This is the reason why there are 2 sessions shown in the Online users form when connecting using BC. It is possible that a person itself logged out from AX, but the worker session has its own alive state. This session type is indicating that e.g. a connection with SSRS was created on behalf of the user. The alerts feature creates threads for each users that has an alert rule in place, and they appear as worker sessions as well.

  • Business Connector – This is used to represent the session that is established when the Logon or LogonAs methods are called using the Business Connector (BC).

  • Web user – that is created when using EP is actually a Worker session inside the AOS but it is represented as a Business Connector session in the database because of the way licenses are counted for EP sessions. One thing to note is that the web user sessions are transient in nature because EP uses session caching and the web user sessions have a very short lifetime as they often map to web page based requests.
useful links:

Wednesday, September 5, 2018

Is in batch

RunBaseBatch class has isInBatch() method. It returns true if the current instance runs as batch, but not if it the class is used by some other batch. 
Session::isServer() - another useful function. 

Wednesday, March 22, 2017

Multi-select on form datasource grid in AX

There is a difference in iterating the selected records on a form datasource depending on how and what the user has selected.

Suppose we have a form with Grid multi select property = TRUE. The form has button with it clicked method overwritten.

There are three ways to get selected records:

1. Iterating marked records on the grid


Here is some sample code:
void clicked()
{
    InventItemGroup itemGroup;

    itemGroup = InventItemGroup_DS.getFirst(1);
 
    while (itemGroup.RecId != 0)
    {
        info(itemGroup.ItemGroupId);

        itemGroup = InventItemGroup_DS.getNext();
    }
}

2. Getting the current record by just accessing the datasource directly


Here is some sample code:
void clicked()
{
    info(InventItemGroup.ItemGroupId);
}

3. Using MultiSelectionHelper class

The MultiSelectionHelper class provides an interface to work with multiple selected records on a form data source.
https://msdn.microsoft.com/en-us/library/cc639186.aspx

Here is some sample code:
void clicked()
{
    InventItemGroup   itemGroup;
    MultiSelectionHelper  helper = MultiSelectionHelper::construct();
    
    helper.parmDatasource(InventItemGroup_DS);

    itemGroup = helper.getFirst();
    while (itemGroup.RecId != 0)
    {
        info(itemGroup.ItemGroupId);

        itemGroup = helper.getNext();
    }
}