RowUpdate

Enables the script to call the same RowUpdate logic that the system user interface utilizes for a given detail row. This command is optional. It is useful, especially for the Formula Ingredient detail because the Quantity % column is calculated for the new row.

Only use RowUpdate for symbols or details that support RowUpdate events in hook scripts. For example, ingrpre(and post)rowupdate on formula Item lines, tppre(and post)rowupdate on Spec Parameters.

Purpose

The function RowUpdate helps the user to update a row for a dataset object via script.

Syntax


RowUpdateReturn RowUpdate(string objSymbol, string objKey, string DetailCode, RowUpdateArguments args, int flags)

Return Value

If the code is successful, it displays a Dataset object for the requested detail code.

Arguments

Argument Description
objSymbol The object type or current object type of the data.
Note: The object type or current object type of the data.
objkey The object key or current object key of the data.
Note: The object type or current object type of the data.
DetailCode The DTLCODE (Detail Code) corresponding to the tabs in the Optiva object need to be specified as these codes identify specific sections or data categories within Optiva.

For example:

  • TPALL — Represents the Parameters tab, containing all parameter details.
  • INGR — Represents the Formula Ingredients tab, listing all ingredients in a formula.
  • HEADER — Represents the Main or Header tab, containing general or summary information.
args args is a data table with data rows that needs to be added in the table. The data row returned from the GetNewRow is passed as a reference, which means the method can not only modify the contents of the row but also replace the variable. The changed values are reflected in your local newIngrRow variable.

Return

ADO.Net DataSet object. Seehttp://msdn.microsoft.com.

Example and workaround for updating formula ingredients and passing the original row

Note: An error message can be encountered when a workflow uses RowUpdateon formula ingredients, while the Formula symbol pre/post Ingredient Row Update event includes Context.GetCurrentRowValue.

When a user is working on the Item Lines of a formula, if a pre/post row update Symbol script needs the original row values (Context.GetCurrentRowValue), the application has passed it to the script and there is no error. However, if a modification comes from a workflow action, the original row value is not normally passed. Then, when the RowUpdate() workflow function causes the pre/post row update to run, the original row value is missing. You can encounter an error such as “Cannot perform '=' operation on System.Double and System.String". This condition can be avoided with a simple modification:

Example Symbol script excerpt:

Dim currVals As Object = Context.GetCurrentRowValue(“UOM_CODE”)

Example Action script excerpt:

Dim IngrTableName As String = DataSetTableName("FORMULA",_OBJECTKEY, "INGR")
Dim rows as DataRow
Dim ds As DataSet = ObjectDataSet("FORMULA",_OBJECTKEY)
Dim IngrTable As DataTable = ds.Tables(IngrTableName)
Dim rowcnt As Integer=IngrTable.Rows.Count-1
while k <= rowcnt
rows=IngrTable.Rows(k)
rows("UOM_CODE")="KG"
rows("ATTRIBUTE3")="A"
RowUpdate("FORMULA",_OBJECTKEY,"INGR",rows) 

In the Action script, Use the workaround below to in place of the last line of code above:

Dim origRow as DataRow = rows.Table.NewRow
origRow.ItemArray = rows.ItemArray
RowUpdate("FORMULA",_OBJECTKEY,"INGR",rows, origRow)

Below example determines to update ITEM1 qty to 2 kg in the Item Lines tab of the formula.

// get the object
			DataSet ds = ObjectDataSet(symbol, formulaKey, "INGR");

			// get the ingridents table
            string ingrTableName = DataSetTableName(symbol, formulaKey, "INGR");
           DataTable ingrTable = ds.Tables[ingrTableName];

			// pick the first Row and update the qty
			DataRow[] rows = ingrTable.Select($"ITEM_CODE = "ITEM1");
            if (rows.Length > 0)
            {
                rows[0]["QUANTITY"] = 2;
                RowUpdate(symbol, formulaKey, "INGR", ref rows[0]);
			}
Note: ObjectDataSet(symbol, formulaKey, "INGR") returns a DataSet containing all the data rows and related tables for the specified tab (INGR = Formula Ingredients) of the given object.