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

MES Stateless API

General Coding Comments

The MES API wrapper uses a result object to capture error messages, if any, from the API call. All calls must include a check on the aaMES.Result object to determine if the call was successful or not.

Most calls that update the database, require a valid session. For such calls, you must save the SessionID in a UDA, log into it, and check at the top of the script. The following is an example:

System Platform

IF me.SessionID > 0 THEN
      'main code block
EndIf;

Visual Basic . Net

If gSessionID > 0 Then
      'main code block
End If

 

The following procedure can be used to convert the syntax of the help into usable scripts:

  1. Determine the Stateless API call that you want to convert.
  2. Click .
  3. Paste in the script editor.
  4. Convert the declarations to match the language requirements. For System Platform, add the “;” at the end of the function call (Refer to the Data Types section).
  5. Add the aaMES.NameSpace.aa to the method (Refer to the Stateless API Wrapper section for converting the namespaces). You can use the following for the GetEntityId method.

    value = aaMES.Core.aaEnt.GetEntityId(entName, site);
  6. Add the result object (For example: Dim aaResult As aaMES.Result).
  7. Set the function call to result object. The following is an example for the GetEntityId method:

    aaResult = aaMES.Core.aaEnt.GetEntityId(entName, site);
  8. Set arguments as required, after the declarations. The following is an example for the GetEntityId method:

    entName = me.entityName;
    Site = "";
  9. Add the check for the call status. The following is an example that sets a resultText UDA and logs the message to the logger (On success, you would normally not log):

    IF aaResult.Success THEN

        me.resultText  = "GetEntityId PASSED"; 

        LogMessage(me.resultText);

    ELSE

        ent_id = -1;

        me.resultText  = "GetEntityId Failed, error:" + aaResult.Exception.Message; 

        LogMessage(me.resultText);
    ENDIF;
  10. If the call has a dataset, you can get the required values. For theGetEntityId method, the resultset has the entity id. For example:
     
    value = Result.DataSet_value;
    ent_id = value.Tables(0).Rows(0).Item( "ent_id" );

 

The following is the completed example for System Platform:  

Dim aaResult As aaMES.Result;
Dim entName As String;
Dim site As String;
Dim value As System.Data.DataSet;
 
entName = me.entityName;
Site = "";

aaResult = aaMES.Core.aaEnt.GetEntityId(entName, Site);
IF aaResult.Success THEN
 value = Result.DataSet_value ;
 IF DS.Tables(0).Rows.count > 0 THEN
  ent_id = value.Tables(0).Rows(0).Item( "ent_id" );
  me.resultText  = "GetEntityId PASSED, EntityID =" + ent_id; 
  LogMessage(me.resultText);
 ELSE
  ent_id = -1; 
  me.resultText  = "GetEntityId PASSED, no entity found.";
 ENDIF;
ELSE
 ent_id = -1;
me.resultText  = "GetEntityId Failed, Entity  =" + entName + ", error:" + aaResult.Exception.Message; 
 LogMessage(me.resultText);
ENDIF;

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