Talk:Portal:Data Connectivity
From DataFlex Wiki
(Redirected from Talk:Portal:Data Dictionaries)
One thing VDF is missing is an event that fires after a record is found & all relates, constrains, etc. are done.
Matthew Davidian responded to a post of mine in the VDF newsgroup with a great solution. I've expanded it to cover VDF 11.1 & later - which use FindByRowID instead of Find_By_Recnum.
After putting the code below in your DataDictionary subclass, put the following in a local DataDictionary (one in a view, dialog, etc.):
Object oTable_DD is a Table_DataDictionary Set DDO_Server to oParent_DD Set AfterRecordFound_msg to ProcName Procedure ProcName Do something Do something else End_Procedure
The code for your DataDictionary class:
Class MyDataDictionary is a DataDictionary
// Construct_Object: Object constructor. Procedure Construct_object Forward Send Construct_Object
// Define new Properties: Property {Type} {pxName} {initial_value}
// Set this property in Local DD to a local proc // that will get called after records are found Property String AfterRecordFound_msg ""
// Create child objects
// Set property values: End_Procedure
// Below three procs from Matthew Davidian to create a proc // that runs after Finds/constraints, etc. are done // GM Added Procedure FindByRowID
Procedure Request_Find Integer iFind_Mode# Integer iFile# Integer iIndex# Integer iAfterRecordFound
Forward Send Request_Find iFind_Mode# iFile# iIndex#
[Found] If (AfterRecordFound_msg(Self)) Begin Get AfterRecordFound_msg to iAfterRecordFound Send iAfterRecordFound iFile# Indicate Found True End End_Procedure
Procedure Find_By_Recnum Integer iFile# Integer iRec# Integer iAfterRecordFound
Forward Send Find_By_Recnum iFile# iRec#
[Found] If (AfterRecordFound_msg(Self)) Begin Get AfterRecordFound_msg to iAfterRecordFound Send iAfterRecordFound iFile# Indicate Found True End End_Procedure
Procedure Request_Assign Integer iFile# Integer iAfterRecordFound
Forward Send Request_Assign iFile#
[Found] If (AfterRecordFound_msg(Self)) Begin Get AfterRecordFound_msg to iAfterRecordFound Send iAfterRecordFound iFile# Indicate Found True End End_Procedure
Procedure FindByRowID Integer iFile# RowID riRowId Integer iAfterRecordFound
Forward Send FindByRowId iFile# riRowId
[Found] If (AfterRecordFound_msg(Self)) Begin Get AfterRecordFound_msg to iAfterRecordFound Send iAfterRecordFound iFile# Indicate Found True End End_Procedure