How to check caller is EP in X++

1.5k Views Asked by At

I need to check in X++ if the caller is EP or Client so I can do some customization if the caller is EP in that code. Please let me know how is it possible

Note: I am using ListPageInteraction class for both EP and AX Client and I have to made some modification to same query (used for both) in case the caller is EP in ListPageInteraction class

1

There are 1 best solutions below

2
On

Check the NumberSeqNumCache.isEpClient method, it looks like this:

/// <summary>
///    Determines whether the request is from EP.
/// </summary>
/// <returns>
///    true if EP is the caller; otherwise, false.
/// </returns>
static server boolean isEpClient()
{
     xSession session = new xsession();
     boolean isEP = false;
     sysClientSessions clientsessions;
     ;


    select ClientType from clientsessions where clientsessions.SessionId == session.sessionId();

    if (clientSessions.ClientType == SessionType::WebUser || clientsessions.clientType == SessionType::Worker)
    {
         isEp = true;
    }

    return isEp;
}

It checks if the current session is of type webuser or worker. If you ware using a client, the session would be of type SessionType::GUI. Mind though that other sessions may also register as type SessionType::Worker, for example batch tasks so this might not work everywhere.