APIPut
You can use the APIPut function to update existing data by sending a request to the server. The function updates records that already exist in Optiva.
When to use
You can use this function when:
- You need to modify specific fields of Item, Formula, Project, or other existing Optiva object.
- You need to modify selected fields without affecting other data.
Note: This function is used for specific modifications like status changes or single field updates.
When not to use
You cannot use this function:
- To create new records.
Note: You can use the
APIPostfunction to create a new record. TheAPIPutfunction needs an existing record. - When the object does not exist.
Note: You can use the
APIGetfunction to verify if the record exists before calling this function. TheAPIPostfunction creates and updates a record.
Syntax
FsSrvAppResponse APIPut(string objSymbol, string objectKey, string inputJSON);
Parameters
| Parameter | 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 | Optional |
The key of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| inputJSON | string | Yes | The JSON-formatted string that contains the data to save. |
Return Value
The application returns an FsSrvAppResponse object containing:
- The success or failure status.
- The status information about the request.
- Any error messages if the request fails.
Examples
- Example 1
-
APIPut — Update FSITEM.DESCRIPTION
using System; using Formation.Shared.Defs; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { try { string payload = "{\"FSITEM\":[{\"DESCRIPTION\":\"MKPTEST2 - EN Desc\"}]}"; FsSrvAppResponse resp = APIPut(_OBJECTSYMBOL, "MKPTEST2", payload); if (resp == null) { MessageList("APIPut returned null response."); return 0L; } if (resp.hasErrors) { MessageList("Error occurred while updating"); var errs = resp.ProcessErrors()?.errors; if (errs != null) { foreach (var e in errs) { MessageList(e); } } return 0L; } MessageList("Item Updated"); return 1L; } catch (Exception ex) { MessageList("Exception in wf_start: " + ex.Message); return 0L; } } }