LoadTableValues()
This code sample describes how to create a script that loads information about the Table Values data type that is stored in the database tables. This script is called by the LoadTaskWorkData() script to retrieve the previously specified values for the workflow attribute fields on the Project and Customer pages on the Table Values tab in the work package for a particular workflow. This ensures that the most recent values are displayed on the Project and Customer pages throughout the execution of the workflow.
Function Assoc LoadTableValues( \ Object prgCtx, \ Integer workID ) Assoc project Assoc retVal Dynamic sqlResult Object session = prgCtx.WSession() Object connect = session.fDbConnect //Retrieve the current values of the workflow attribute fields on //the Project page for this workflow from the database table. //The workflow ID is used to determine the current values of the //workflow attributes for this particular workflow. sqlResult = CAPI.Exec( connect.fConnection, \ 'select * from Cust_Project where WorkflowID = :A1', \ workID ) //Store the information that you retrieved from the database //tables in an Assoc named project. if ( session.CheckRetVal( sqlResult ) && Length( sqlResult ) ) project = Assoc.FromRecord( sqlResult[ 1 ] ) //Remove the workflow ID from the project Assoc. Assoc.Delete( project, 'WorkflowID' ) //Retrieve the values of the workflow attribute fields on the //Customer page for this workflow from the database table. //The workflow ID is used to determine the current values of //the workflow attributes for this particular workflow. sqlResult = CAPI.Exec( connect.fConnection, \ 'select * from Cust_Customers where ' + \ 'WorkflowID = :A1', \ workID ) //Store the information that you retrieved from the database //tables in an Assoc named project.Customer. if ( session.CheckRetVal( sqlResult ) && Length( sqlResult ) ) project.Customer = Assoc.FromRecord( sqlResult[ 1 ] ) //Remove the workflow ID from the project.Customer Assoc. Assoc.Delete( project.Customer, 'WorkflowID' ) retVal.Fields = project retVal.NonEditable = {} retVal.Required = {} retVal.WorkflowID = workID else //If unsuccessful, return an error. retVal = sqlResult end else //If unsuccessful, return an error. retVal = sqlResult end return( retVal ) end