SaveTableValues()

This code sample describes how to create a script that saves the values that a workflow participant specifies for the workflow attribute fields on the Customer and Project pages. This script is called by the UpdateTableValues() script after the previous values have been deleted from the database by the DeleteWorkData() script.

		Function Boolean SaveTableValues( \
			Object 		prgCtx, \
			Integer 	workID, \
			Assoc 		data )
			
			Boolean 	success
			Dynamic 	sqlResult
			Assoc 		fields = data.Fields
			Assoc 		customer = data.Fields.Customer
			Object 		session = prgCtx.WSession()
			Object 		connect = session.fDbConnect

			//In the database tables, store the workflow ID, along with the
			//values of the Project Name, Project Code, Due Date, and
			//Priority fields, as specified on the Project page at the time
			//that this script is called.

		sqlResult = CAPI.Exec( connect.fConnection, \
					'insert into Cust_Project( WorkflowID,' + \
					'Project_Name, Priority, DueDate, ID_Code ) ' + \
					'values ( :A1, :A2, :A3, :A4, :A5 )', \
					workID, \
					fields.Project_Name, \
					fields.Priority, \
					fields.DueDate, \
					fields.ID_Code )
		success = session.CheckRetVal( sqlResult )
		
			//In the database tables, store the workflow ID, along with the
			//values of the Customer Name, Address 1, Address 2, City, State,
			//Zip Code, Phone, and Fax fields, as specified on the Customer
			//page at the time that this script is called.

		if ( success )
			sqlResult = CAPI.Exec( connect.fConnection, \
						'insert into Cust_Customers( WorkflowID,' + \
						'Name, Addr1, Addr2, City, State, Zip, Phone,' + \
						'Fax ) ' + \
						'values ( :A1, :A2, :A3, :A4, :A5, :A6, :A7,' + \
						':A8, :A9 )', \
						workID, \
						customer.Name, \
						customer.Addr1, \
						customer.Addr2, \
						customer.City, \
						customer.State, \
						customer.Zip, \
						customer.Phone, \
						customer.Fax )
			success = session.CheckRetVal( sqlResult )
		end
	return( success )
end