Parameter | Description |
---|---|
iFile | Number of the table in the current filelist |
riRowId | The RowId record identity of the record to find |
Procedure FindByRowId integer iFile RowId riRowId
Call: | Send FindByRowId iFile riRowId |
The FindByRowId procedure finds a record in a specified table with the record identifier equal to the passed RowId. If it is found, a relate occurs and all affected parent and child DDOs are updated. If the find succeeds, the Found indicator is set to True. All DDOs that result in a changed record will receive the OnNewCurrentRecord event.
The first parameter, iFile, may be a table name constant (e.g. Customer.File_Number) or an integer variable representing the table (e.g. (Main_File(Self)) ).
The second parameter, riRowId, must be of type RowId.
This method is normally used to refind a record. Typically you will store the current RowId value of a DDO, perform some operation which may change that record, and refind the original record using FindByRowId. The following examples shows how this is done.
Procedure ProcessInvoices RowId riCurrentInvoice Get CurrentRowId of oInvoices_DD to riCurrentInvoice Send RunInvoiceReport // assume that running this report may change the current record of the DDO // therefore we will restore the DDO back to the record we started with Send FindByRowId of oInvoices_DD Invoices.File_Number riCurrentInvoice End_Procedure
If the find fails, the DDO will be cleared. You can use the Found global indicator to determine if a find was successful. If you do this, you must test the value immediately after the find as this indicator is volatile and could be changed by subsequent commands. Alternately, you can use the HasRecord function to test if a record exists after the find.
Procedure RefindIt Handle hoDD RowId riRow Boolean bFound integer iMain Get Main_File of hoDD to iMain // find based on main table of passed DD Send FindByRowId of hoDD iMain riRow Move (Found) to bFound // move the value of the Found indicator to bFound immediately after the find : End_Procedure // an alternate Procedure RefindIt Handle hoDD RowId riRow Boolean bFound integer iMain Get Main_File of hoDD to iMain // find based on main table of passed DD Send FindByRowId of hoDD iMain riRow Get HasRecord of hoDD to bFound : End_Procedure
If you need to find a specific record based on some other known value (e.g.: a customer Id or an order number) you will use the Find or Request_Find methods.
You can refind a record by RowId without changing the DDO's current record with the ReadByRowId method.
Refind_Records checks to see if the record in the global table buffer is the same as the record in the DDO Field Buffer and refinds the record if needed.
FindByRowId is not re-entrant. Once a major Data-Dictionary operation (save, find, delete, clear) has begun you cannot start another major operation. The reentrancy restriction applies within DDO structures and across DDO structures.
Data Dictionary SQL Filters cannot be used with this method. See pbUseDDSQLFilters for a list of methods that can use DD SQL filters.
This method is sometimes confused with the global function FindByRowId, since it shares the same name. The difference is that the method in the BaseData_Set class works on local DD buffers, while the global function works on the global file buffer.
See AlsoFinding - Find, Request_Find and FindByRowId | Find and Clear Operations in DDOs | OnNewCurrentRecord | HasRecord | CurrentRowId | Find | Request_Find | ReadByRowId