Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

MES Stateful API

Logging on to Entities

After the user logs on, the user will need to log on to one or more entities.  If you are using .NET controls in your application, they can be set up to display a dialog for allowing the user to log onto one or more entities.

You can call the LogonEnt script after setting UDA (me.EntityName) with the entity name you want to log on. You should mark this as an asynchronous script.

You can use the LogonEnt script as an Execute or OnTrue script with a UDA trigger (me.LogonEntTrig).

' LogonEnt Script
 dim clientSession As aaFactMES.aaClientSession;
 dim result As aaFactMES.Result;
 dim entityID as Integer;
 ' reset the trigger
 me.LogonEntTrig = false;
 ' Get the singleton client session
 result = aaFactMES.aaClientSession.GetInstance();
 clientSession = result.Value;
 if ( clientSession <> null ) then
    if ( clientSession.curUser <> null and me.EntityName <> "" ) then
    ' get Entity ID from input UDA Entity Name
    result = aaFactMES.aaEnt.EntIdFromName( me.EntityName );
       if ( result.Success == true and result.Int32_Value <> -1) then
         ' go an entity ID - attempt to logon
         entityID = result.Int32_Value;
         result = clientSession.curUser.LogonEnt( entityID, "", 100.0 );
           if ( result.Success == true ) then
           ' Print Success message
            LogMessage(clientSession.curUser.userName + " has logged onto entity " + me.EntityName + " - id=" + StringFromIntg(entityID, 10) );
           endif;
        else
        ' Failed to get Entity ID from Entity Name
         LogMessage("Entity " + me.EntityName + " does not seem to exist");
        endif;
     endif;
endif;

TitleResults for “How to create a CRG?”Also Available in