CommitNewRow

Adds the new row that is returned from the GetNewRow command to the data table. Rows can be committed to the table only if each column that requires a value has a value. If a row with same key value already exists in the table as the new row, then an exception is thrown.

Purpose

The function CommitNewRow adds the new row obtained from the GetNewRow command to the data table and the row can only be committed if all required columns contain values. If a row with the same key value already exists in the table as a new row, the operation throws an exception to prevent duplication.

Syntax

void CommitNewRow(string objSymbol, string objKey, string DetailCode, ref object[] RowValuesToAdd)

Return Value

If the code is successful a value zero (0) is displayed.

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.
RowValuesToAdd

The data row that is 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 itself. The changed values are reflected in your local newIngrRow variable.

CommitNewRowProcess

  1. Get a new data row object using GetNewRow()
  2. Set the necessary values into this newly fetched row by assigning key-value pairs representing the data fields.
  3. Call the CommitNewRow to save it to database.

Examples

Add a new row with item BYPRODUCT1_AH of 1 KG in the Byproducts tab.

//Returns a new datarow
			DataRow newIngrRow = GetNewRow("", "", "BYPROD");
			
			//Set the values in the datarow
			newIngrRow["ITEM_CODE"] = "BYPRODUCT1_AH";
			newIngrRow["QUANTITY"] = 1;
			newIngrRow["UOM_CODE"] = "KG";
			
			//Add the data in the newly added row
			CommitNewRow("", "", "BYPROD", ref newIngrRow);

Add Item in Byproducts tab of Specification and provide Qty%, Qty% Hi, Qty% Lo for the same.

//Returns a new datarow
			DataRow drNewRow = GetNewRow("", "", "BYPROD");
			
			//Set the values in the datarow
			drNewRow["ITEM_CODE"] = "IT1";
			drNewRow["QUANTITY"] = "20";
			drNewRow["QUANTITY_HI"] = "40";
			drNewRow["QUANTITY_LO"] = "10";
			
			//Add the data in the newly added row
			CommitNewRow("", "", "BYPROD", ref drNewRow);

Add Formula in Formula tab of Ingredient Statement.

//Returns a new datarow
			DataRow drNewRow = GetNewRow("", "", "LFORM");
			
			//Set the values in the datarow
			drNewRow["FORMULA_CODE"] = "FORM1\\001";
			
			//Add the data in the newly added row
			CommitNewRow("", "", "LFORM", ref drNewRow);
Note: The DTLCODES of Formula tab, Ingredient Statement Rules Tab are LFORM and LRULE respectively.

Add a new row with label "Salt Label ENUS" for English language code in Labels tab of Item SALT.

//Returns a new datarow
			DataRow newlblrow = GetNewRow("ITEM", "SALT", "LABEL");

			//Set the values in the datarow
			newlblrow["LINE_SORT_ORDER"] = 1;
			newlblrow["LANGUAGE_CODE"] = "EN-US";
			newlblrow["LABEL_TEXT"] = "Salt Label ENUS";

			//Add the data in the newly added row
			CommitNewRow("ITEM", "SALT", "LABEL", ref newlblrow);

Add a new row with Claim text for English language code in Manual Claims tab of Label Content LC\001.

//Returns a new datarow
			DataRow drNewRow = GetNewRow("LABELCONTENT", "LC\001", "MCLAIM");
			
			//Set the values in the datarow
			drNewRow["TYPE_IND"] = "1";
			drNewRow["CLAIM_TEXT_EN-US"] = "Manual Claim statement 1 text entered manually on label content – ENUS.";
			drNewRow["REPORT_IND"] = "0";
			
			//Add the data in the newly added row
			CommitNewRow("", "", "MCLAIM", ref drNewRow);

Add extension table data in FORMULA.

Note: MATRIX.V\<tableName> is the detail code used to add/update extension table rows. Eg: MATRIX.V\ITEM0
//Returns a new datarow
			DataRow drNewRow = GetNewRow("", "", "MATRIX.V\\ITEM0");
			
			//Set the values in the datarow
			drNewRow["FIELD2"] = "Brand-X";
			drNewRow["FIELD3"] = "100";
			drNewRow["FIELD4"] = "9/7/2025";
			
			//Add the data in the newly added row
			CommitNewRow("", "", "MATRIX.V\\ITEM0", ref drNewRow);