On Nov 3, 2012, at 11:59 AM, Peter Gutbrod wrote:

> I'd like to load a selection of records into a RowSet.
> 
> But for a few of them, tagged with a label, I'd like to load the data from a
> different record of the SAME table into the RowSet, except for a few fields
> of the original record.
> 
> The "related" record is referenced within the original record (via ID field
> of the related record).
> 
> It seems, it is the same problem you have with 4D's "Apply to Selection"
> command, that you may not alter the current selection within the loop, which
> is imminent to find the related record within the same table.
> 
> Any suggestions, how to accomplish this task?

Have not done any 4D in a couple years so I can't test my theories, or even 
want to try to write pseudo code.


First of all have you tried a callbacks? Don't think it is called until the 
record is  loaded, i.e. the selections is not messed up when you're building 
the rowset. Might even be able to do it with a column callback.

#map := """

field:  [table]field1
related:  `get_related`
...
"""

where the method get_related is  callable from the column, might have to put a 
global variable in it?. Then stuff a collection of the related data elements 
into the map column. Again, not sure it will work but I've used column calls to 
do some weird stuff.

Another approach, if there are not thousands or related records is query the 
related records (you mentioned a label, or maybe a non-zero id)

Look through the selection and suff the data you need into a collection with a 
key being the related id (as string).  You'd have access to the related 
collection (build where rowset is built) so don't even have to put it in a 
column. If the row has a related record, just use the related_id as string to 
get the other columns and do what you need to do.

if($row{"related_id"} > 0
        $row{"field3"}  := $rel_coll{string($row{"related_id"})}{"field3"}

end if


or something like that.

Steve

_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to