APIGet
You can use the APIGet function to retrieve the data by sending a request to the server. The function retrieves object data programmatically in the scripts.
When to use
You can use this function to:
- Retrieve data from an Item, Formula, Project, or other Optiva object during script execution.
- Validate the related data and verify the expected values before saving or processing.
Syntax
FsSrvAppResponse APIGet(string objSymbol, string ObjectKey);
Parameters
| Description | Type | Required | Description |
|---|---|---|---|
| objSymbol | string | Optional |
The symbol of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| objKey | string | Yes |
The key of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
Return Value
An FsSrvAppResponse object containing the retrieved data, the status information about the request, and an error message is returned if the request fails.
Examples
- Example 1
-
The workflow action that calls
APIGetfor the current workflow object, validates the returned DataSet contains an "FSITEM" table and at least one row, and logs the DESCRIPTION field of the first row.using System; using System.Data; using Formation.Shared.Defs; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { try { // Call APIGet for the current workflow object FsSrvAppResponse data = APIGet(_OBJECTSYMBOL, _OBJECTKEY); if (data == null || data.reponseDataSet == null) { MessageList("APIGet returned no data."); return 0L; } DataSet ds = data.reponseDataSet; // Validate the expected table and row exist if (!ds.Tables.Contains("FSITEM") || ds.Tables["FSITEM"].Rows.Count == 0) { MessageList("FSITEM table is missing or contains no rows."); return 0L; } DataRow row = ds.Tables["FSITEM"].Rows[0]; // Safely read DESCRIPTION and log it object descrObj = row["DESCRIPTION"]; string descr = descrObj != null ? descrObj.ToString() : "(null)"; MessageList("The Description is: " + descr); return 1L; } catch (Exception ex) { MessageList("Exception in wf_start: " + ex.Message); return 0L; } } }