web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Tip - How to Retrieve AOS Instance name in Dynamics AX via X++ Code

Dilip Profile Picture Dilip 1,164
One of my mates asked me how to retreive AOS Instance name through code. My first impression was that it should be somewhere in the Global Class. But, soon figured out I was wrong, then I jumped into Session Class which has a static method getAOSInstance() which retreives the instance number

The requirement here was to extract the instance name. Suddenly, it striked me, that in standard AX in Administration > Online Users form, the last column shows the AOS instance name.

So, the next step was to go through AOT > Forms > SysOnlineUsers > display method getAOSInstanceName() -  here the key is serverSessions.aosId and serverSessions.Instance_Name - combination of both will give you the aos instance.

//BP Deviation documented
display ServerId getAOSInstanceName(SysServerSessions serverSessions)
{
    ServerId            sid = '';
    str                 aosId, machineName, instanceName;
    int                 pos;
    #DEFINE.ATSYMBOL('@')
    ;
    aosId = serverSessions.aosId;
    instanceName = serverSessions.Instance_Name;
    pos = strfind(aosId, #ATSYMBOL, 1, strlen(aosId));
    machineName = substr(aosId, 1, pos-1);
    sid = instanceName + '@' + machineName;
    return sid;
}

Sometimes Googling within AX helps  Njoi  ;-)









This was originally posted here.

Comments

*This post is locked for comments