ObjectDataSet
You can use the ObjectDataSet function to retrieve an ADO.NET DataSet object for a specified Optiva object, such as a formula, item, or project. The DataSet contains the objects data grids and detail sections for programmatic data manipulation and querying.
When to use
You can use this function to:
- Query formula ingredients with specific filters.
- Search for items matching multiple criteria.
- Aggregate data across detail lines.
- Process all ingredients in a formula programmatically.
- Batch update multiple detail lines.
When not to use
You cannot use this function for:
- Simple object retrieval.
Note: Use
ObjPropertyto fetch the value. - Simple parameter retrieval.
Note: Use param(), valparam(), or tparam() for simple parameter access in equations.
- Displaying data.
Note: Use the built-in UI functions.
Syntax
DataSet ObjectDataSet(string objSymbol, string objKey, string dtls = "HEADER");
Parameters
| Parameter | Required | Type | 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.
|
|
| dtls | string | Yes |
The semicolon-delimited list of detail codes to load in the DataSet.
Note: Use "HEADER" for header only.
|
Return Value
An ADO.NET DataSet object containing the requested objects data is returned.
Note: See https://ADO.NET%20DataSet%20Documentation for full DataSet capabilities.
Impact
DataSet objects can consume significant memory for large objects.
Prerequisites
- The detail codes need to be valid for the object type.
- If another Optiva script function, except
MessageList, is called, the in-memory DataSet is dropped.
Note: If looping through DataTables or DataRows, avoid calling other Optiva functions.
ADO.NET DataSet Useful Methods
| Method/ Property | Description | Example |
|---|---|---|
| Tables | Collection of DataTables. | ds.Tables["INGREDIENT"] |
| Tables.Contains() | Check if the table exists. | ds.Tables.Contains("INGREDIENT") |
| GetXml() | Export as XML. | string xml = ds.GetXml() |
| Select() | Filter rows. | table.Select("QUANTITY > 10") |
| Compute() | Aggregate calculations. | table.Compute("SUM(QTY)", "") |
| Rows.Count | Number of rows. | table.Rows.Count |
Examples
- Example 1
-
Basic DataSet retrieval
using System; using System.Diagnostics; using System.Data; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { DataSet ds = ObjectDataSet("", "", "HEADER;NOTIFICATION"); DataTable dt = ds.Tables["FSOBJECTNOTIFICATION"]; foreach (DataRow dr in dt.Rows) { string propName = dr["PROPERTY_NAME"].ToString(); string msgCode = dr["NOTIFY_MESSAGE_CODE"].ToString(); int severity = Convert.ToInt32(dr["SEVERITY"]); string msgStr = string.Format("The property {0} has a message code of {1} with severity {2}", propName, msgCode, severity); MessageList(msgStr); } return 111; } }
- Description
- This C# workflow script retrieves notification data from an Optiva objects DataSet and iterates through the FSOBJECTNOTIFICATION table to display each notifications property name, message code, and severity level. It shows how to access and process object detail data within a workflow action using ADO.NET DataSet and DataTable objects.