Kbase P80317: Dyn: How to make a treeview container filter on a newly created root record
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/05/2004 |
|
Status: Unverified
GOAL:
How to make a Treeview container filter on a newly created root record
FACT(s) (Environment):
Dynamics 2.1A
FIX:
The following solution has been tested successfully with 2.1A02 and works fine in a thin client environment:
In short:
The idea is to catch updateState with "updateComplete" in the SDV that created the new record. At that point it is a bit too early to ask the filter viewer to apply a new filter because the flow of calls initiated by updateRecord is not finished yet (at least, some important API need to complete **). So once this event is caught we have to set a NewRecordToFilterTvOn flag in the SDV.
Later, after SUPER of updateRecord you take this flag into account to ask the filter viewer to filter on the new record
With more details:
0) This has to be implemented in the super procedure of the viewer of the root record that is added (the one used in the folder window)
1) Make an override of addRecord. After RUN SUPER, set a NewRecBeingCreated flag to yes. Note that if you want your viewer to be just compliant with SuperProcedureMode set to STATEFUL then this flag could be just a global variable (definition block of the SDV super proc). On the other hand, if you want the SDV to be compliant with SuperProcedureMode set to STATELESS, then you should implement this NewRecBeingCreated flag in a userProperty (set set/getUserProperty).
2) Make an override of updateState. After RUN SUPER, if NewRecBeingCreated and if pcState = "updateComplete" and if NOT DYNAMIC-FUNCTION('anyMessage':U IN TARGET-PROCEDURE)*** then set a new NewRecordToFilterTvOn flag to yes.
3) Make an override of updateRecord. After RUN SUPER, if NewRecordToFilterTvOn then retrieve the key value of the new record to pass to the filter viewer. Call**** a ApplyNewFilter procedure in the filter viewer, passing the key as a parameter. Then reset the two flags back to no (or to blank if userProperty)
4) This ApplyNewFilter procedure should display the new key and do PUBLISH "filterDataAvailable" FROM TARGET-PROCEDURE (INPUT "<cKeyFieldName>,<cKeyValue>,=").
** Note also that calling filterDataAvailable kills the SDO and creates a new instance of it during the process of emptying the treeview, which makes problems in a thin client environment if filterDataAvailable is published from updateState.
*** The point is to ignore a save that failed because the record did not pass validation.
**** You could publish an event from hContainerSource (of the record viewer). The filter viewer would subscribe to this event in its hContainerSource (that happens to be the same as for the record viewer)