Result Object (aa MES. Result)
- Last UpdatedNov 06, 2025
- 3 minute read
All methods in aaMES return a standard Result structure. This structure has a Boolean Success member, which can be checked to determine if the method executed without an error. When an error is detected, Success is set to false and the Exception member contains the caught Exception class.
If the wrapped method returns a value, it is available in the Value member that is of the type Object. The return value must be assigned to a variable of the expected result type. Alternatively, the return value is also stored in the appropriately typed member property. There is a typed member property for each possible type returned by aaMES methods. It is defined as follows:
| System Platform | Dim aaResult As aaMES.Result; |
| Visual Basic .Net | Dim aaResult As aaMES.Result; |
The Result object has the following key properties:
|
Property |
DataType |
Description |
|---|---|---|
| Success | Boolean | Holds the status of the call. If set to True, the call is a success. |
| Value | Object | This is call dependent, and holds the return value of the call. |
| Dataset_Value | Dataset | If the return value is a dataset, it is the same value as the Value property. It is recommended to use the Dataset_Value property. |
| Exception | Exception | Holds a .Net exception object, if an error occurred with the call. |
The following example shows how to use the result object Success property:
System Platform
Dim aaResult As aaMES.Result;
Dim SessionID As Integer ;
Dim ClientType As Integer ;
SessionID = Me.SessionID;
ClientType = aaMES.Core.aaClientTypes.clientOperator;
aaResult = aaMES.Core.aaSession.StartSession(ClientTypes, SessionID);
If aaResult.Success Then
me.resultText = "StartSession PASSED " + SessionID;
Else
me.resultText = "StartSession Failed: " + aaResult.Exception.Message;
EndIf;
Visual Basic .Net
Dim aaResult As aaMES.Result
Dim SessionID As Integer = Me.txtgSessionID.Text
Dim ClientType As Integer = aaMES.Core.aaClientTypes.clientOperator
aaResult = aaMES.Core.aaSession.StartSession(ClientType, SessionID)
If aaResult.Success Then
Me.resultText.Text = "StartSession PASSED " + SessionID.ToString Me.txtgSessionID.Text = SessionID
Else
Me.resultText.Text = "StartSession Failed: " + aaResult.Exception.Message
End If
To use the Dataset_value property the call must be defined to have return value of dataset type. The following is an example:
Dim entName As String
Dim site As String
Dim value As DataSet
value = Ent.GetEntityId(entName, site)
This call defines the return value as follows:
Return Value
Returns a Dataset with the records in the Ent table, which matches the specified entity name and, optionally, site. The returned DataRow includes the entity ID. If no matching record is found, an empty DataSet is returned.
Following are the guidelines for using the returned Dataset:
- Always use the DataSet_value property (do not use the Value property)
- You need to confirm the call success (aaResult.Success) before setting the dataset. If it fails, the DataSet_value will not be set and you could get an exception.
- Always check the row count before using the dataset (IF DS.Tables(0).Rows.count > 0 THEN)
- In Visual Studio, use the .ToString to handle Null values (ds.Tables(0).Rows(0).Item("user_id").ToString). In System Platform, this is handled automatically. The following is an example:
System Platform
Dim aaResult as aaMES.Result;
Dim DS as System.Data.DataSet;
Dim EntityName as String;
Dim ent_id as Integer;
EntityName = me.entityName;
aaResult = aaMES.Core.aaEnt.GetEntityId(EntityName, "" );
IF aaResult.Success THEN
DS = aaResult.DataSet_value ;
IF DS.Tables(0).Rows.count > 0 THEN
ent_id = DS.Tables(0).Rows(0).Item( "ent_id" );
me.resultText = "GetEntityId PASSED, EntityID =" + ent_id;
ELSE
ent_id = -1;
me.resultText = "GetEntityId PASSED, no entity found.";
ENDIF;
ELSE
ent_id = -1;
me.resultText = "GetEntityId Failed, EntityID =" + ent_id + ", error:" + aaResult.Exception.Message;
ENDIF;
me.EntityID = ent_id;
Visual Basic .Net
Dim aaResult As aaMES.Result
Dim DS As System.Data.DataSet
Dim EntityName As String
Dim ent_id As Integer
EntityName = Me.entityName.Text
aaResult = aaMES.Core.aaEnt.GetEntityId(EntityName, "")
If aaResult.Success Then
DS = aaResult.DataSet_Value
If (DS.Tables(0).Rows.Count > 0) Then
ent_id = DS.Tables(0).Rows(0).Item("ent_id")
Me.resultText.Text = "GetEntityId PASSED, EntityID =" + ent_id Else Me.resultText.Text = "GetEntityId PASSED, no entity found."
End If
Else
ent_id = -1
Me.resultText.Text = "GetEntityId Failed, EntityID =" + ent_id + ", error:" + aaResult.Exception.Message
End If
Me.EntityID.Text = ent_id