selectRecord problem

I have a parent/child form and am using selectRecord() on the parent and the child - the parent selectRecord() works perfectly, but the subsequent selectRecord() on the child does not.

The reason it fails is because the child foundset has not reloaded with the data that corresponds to the new parent foundset record.

I am trying to find a way to reload the child foundset but have been unsuccessful.

...
        //
        // determine which form to remove the inventory item from
        //
        var lv_form = 'seis_line_inventory_tab2';
        if ( foundset.item_category == '6' || foundset.item_category == '2')
          lv_form = 'seis_line_inventory_tab1';
        if ( foundset.item_category == '1' )
          lv_form = 'seis_line_inventory_tab3';
        if ( foundset.item_category == '4' )
          lv_form = 'seis_line_inventory_tab4';
        
        //
        // set the top half of the seis_line_inventory screen to the line in question
        // that way the tab will fill with the foundset we are interested in
        // we can then uncheck the record of interest
        //
        lv_rb = forms.seis_line_inventory_lines_list.foundset.selectRecord(args[2]);
        
        
        //
        // now, find the record of interest so we can uncheck it
        //
        lv_rb = forms[lv_form].foundset.selectRecord(args[0],args[1],args[2]);
...

The last line of code is where the problem is - it returns ‘false’. It would return ‘true’ if the child foundset was loaded with the correct data.
If I interrogate the record on the child ,just before the child selectRecord(), I can see that it contains data for the previously selected parent foundset record. I would have thought that when the parent foundset record changed that the child foundset would get reloaded automatically. It does on the form when you see it but not in my code when I do it programmatically.

Any thoughts on how to get the child foundset reloaded before I issue the selectRecord() on it ??

Thanks in advance
Mark

I assume you have a relation from parent to child?
Have you got UseSeparateFoundset checked?
What are args[0], [1] and [2]?

Yes, there is a relation from parent to child - the parent/child forms work great - you change the parent record and the child records populate automatically just fine.

I am not using separateFoundset.

args[…] are the primary key values for the child foundset (in alphabetical order). args[2] is the primary key for the parent foundset.

If the foundset in the forms[lv_form] form is really related to the foundset in which you select the first record and it’s not yet updated to the proper set of related records, please file a case for this.

But, before coming to that conclusion: check the relationName on the foundset (foundset.getRelationname() from the top of my head).

And compare the foundset objects in the forms[lv_form] form with the related foundset object over the realtion. They ought to be equal:
(forms.seis_line_inventory_lines_list.foundset.yourRelationNameHere == forms[lv_form].foundset)

Paul

I checked the relation and it was null :oops:

I checked how the rest of the form was built and I believe I have found the problem - I’m trying to bank on a relation that doesn’t actually exist.
The parent form that I was referring to (call it parent B) is really a child to another parent form (call this one parent A). Parent B is on a tab on Parent A.
The relation that exists between ‘parent’ and child forms is based on Parent A and NOT Parent B. Parent A and Parent B are based on the same table, however.

I think I know what I need to re-engineer now that the problem is obvious.

Thanks for all who chimed in, I appreciate it !!

Take care
Mark

to understand what you want to do: you want to select a record in a related foundset?
So you have a parent somewhere and that changes and the you want to select a record in a child/related foundset?

why are you doing that through:

forms.xxxx.foundset.selectRecord() ??

thats sound already really wrong. because what you want to do is do stuff on the data level. Then dont go through the ui level to do it. (forms.xxx)

what you should do is:

parentfoundset.relationname.selectRecord()

or even better

parentrecord.relationname.selectRecord()

(because that is what you really want to do, set a selection of a related foundset from a record)

Thanks Johan - I can successfully select the record if I use the parentfoundset.releation.selectRecord(…) technique. I’m thinking parentfoundset should be ok because just prior to that I issued a parentfoundset.selectRecord(…) - I should be on the correct parent record at that point.

I have another challenge, however, regarding the clearing of a checkbox on that selected child record that is still problematic, which I’m looking into now.

Cheers
Mark