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.
Syntax
Public Function RowUpdate(ByVal objSymbol As String, ByVal objKey As String, ByVal
DetailCode As String, ByVal updateRow As DataRow, Optional ByVal
originalRow As DataRow = Nothing, Optional ByVal flags As Integer = 0)
As DataSet
Arguments
Argument | Description |
---|---|
objSymbol
|
The data object type or the current object type if blank. |
objKey
|
The data object key or the current object key if blank. |
DetailCode
|
The system detail code that has the
RowUpdate logic to execute.
|
updateRow
|
The
ADO.Net DataRow object that has the current
row values.
|
originalRow
|
Optional. The
ADO.Net DataRow object that has the old row
values.
|
Flags
|
Reserved for future use. |
Return
ADO.Net DataSet
object. See
http://msdn.microsoft.com.
Example and workaround for updating formula ingredients and passing the original row
RowUpdate
on 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 may 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)