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

MES Stateful API

Logging off from Entities

When the user is finished with an entity, they can log off the entity using the Job Summary control or you can script the log off as shown in the LogOffEnt script.

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

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

' LogOffEnt Script
 dim clientSession As aaFactMES.aaClientSession;
 dim result As aaFactMES.Result;
 dim entityID as Integer;
 ' reset the trigger
 me.LogoffEntTrig = 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 logoff
                   entityID = result.Int32_Value;
                   result = clientSession.curUser.LogoffEnt( entityID );
                          if ( result.Success == true ) then
                               LogMessage(clientSession.curUser.userName + " has logged off of 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