Copying extension table data to an Optiva object
You can use this sample script to copy extension table data from the Wizard to an Optiva object. In this script example, you can copy extension table data from the Wizard to the Specification > Parameters grid. This script also creates a new Specification object.
Replace the View ID in the script with the View ID in the Extension
Table Definition form. The View ID is the numeric value that is displayed
after DMACTIONWIP
in the sample script. The script must
match the View ID in the Extension Table Definition
form.
Option Strict Off
Imports System
Imports System.Data
Imports System.Diagnostics
Class ActionScript
Inherits FcProcFuncSetEventWF
Function wf_approve() As Long
Try
Dim oLine As Object = ObjProperty("FIELD5.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", _WIPID, "*")
Dim sSpecCode As String = GenerateCodeNumber("CREATE SPECIFICATION")
Dim sDescr As String = WIPPARAMGET("DESCRIPTION")
Dim saveStatus As Long = ObjectSaveAs("SPECIFICATION", "@DFLT", sSpecCode)
Messagelist("Created Spec ", sSpecCode)
ObjPropertyset(sDescr, 0, "DESCRIPTION", "SPECIFICATION", sSpecCode)
Dim exists As Long = ObjectExists(sSpecCode, "SPECIFICATION")
If exists = "1" Then
For i As Integer = 0 To oLine.length - 1
If Not oLine(i) Is DBNull.Value AndAlso Not oLine(i) Is Nothing AndAlso IsBlank(oLine(i)) = 0 Then
'Messagelist("Line # ", CStr(oLine(i)))
Dim oLabel As Object = ObjProperty("DM_ROW_LABELS.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", "", CStr(oLine(i)), "FIELD5")
Dim dField1 As Object = ObjProperty("FIELD1.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", "", CStr(oLine(i)), "FIELD5")
Dim dField2 As Object = ObjProperty("FIELD2.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", "", CStr(oLine(i)), "FIELD5")
Dim dField3 As Object = ObjProperty("FIELD3.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", "", CStr(oLine(i)), "FIELD5")
Dim dField4 As Object = ObjProperty("FIELD4.MATRIX.V\DMACTIONWIP0", "ACTIONWIP", "", CStr(oLine(i)), "FIELD5")
'Messagelist("Line # ", CStr(oLine(i)), " Label ", oLabel, " Min ", dField1, " Max ", dField2, " Target ", dField3, " Comment ", dField4)
'Messagelist("Adding Rows to Spec ", sSpecCode)
'Add a row and Set values
Dim ds As DataSet = ObjectDataSet("SPECIFICATION", sSpecCode)
Dim ParamTblName As String = DataSetTableName("SPECIFICATION", sSpecCode, "TP")
Dim ParamTbl As DataTable = ds.Tables(ParamTblName)
Dim newParamRow As DataRow = GetNewRow("SPECIFICATION", sSpecCode, "TP")
newParamRow("LINE_ID") = CInt(oLine(i))
newParamRow("PARAM_CODE") = oLabel
newParamRow("MINVAL") = dField1
newParamRow("MAXVAL") = dField2
newParamRow("TARGET") = dField3
newParamRow("COMMENTTXT") = dField4
'RowUpdate("SPECIFICATION", sSpecCode, "TP", newParamRow) NOT USED FOR SPEC PARAMETER TAB
CommitNewRow("SPECIFICATION", sSpecCode, "TP", newParamRow)
Else
Messagelist("No Lines - Ending Calculation")
Return 111
End If
Next i
Messagelist("Starting Spec ", sSpecCode)
StartForm("frmspecification", sSpecCode)
Else
Messagelist("Create Specification Failed ", sSpecCode)
End If
Catch ex As Exception
MessageList("Try-Catch Wizard CT Copy: ", ex.ToString)
End Try
Return 111
End Function
End Class
Example of copying extension table data to a Specification object in Optiva
- Create an action with the sample script.
- Create an extension table in the Extension Table Definition form.
- Create a Create Rule for an object.
- Create an action set. Specify the action that was created in Step 1 in the Action Code field.
- Launch a wizard for the action set. Specify values for the extension table and click Specification object is created and the values that were specified in the Wizard form are displayed in the Specification > Parameters grid. . A new