Really strange showRecords issue

I’ll be very happy if anyone can explain this:

Form A has a non-related tab panel showing records from table B on form B which are loaded via an sql select as part of an onShow method belonging to form B. Despite being a non-related tab the records ARE related to the record on form A, but I am using a non-related tab because only a subset of records are shown on form B which varies according to the current user.

The finding and loading of records into the tab panel B works perfectly except for one particular set of actions: I go to one of the records showing in the tab using a button linked to a method which simply uses formB.controller.showRecords(foundset) - this takes me to the record card for that record in table B; then I have a button on this card to take me back to the record on form A using ```
forms.sections_card.controller.showRecords(formB_to_formA);


In both cases the methods triggered are the same, the query generated is the same, the dataset resulting from the query is the same, the method steps are the same and yet one route results in no records loaded <img src="{SMILIES_PATH}/icon_exclaim.gif" alt=":!:" title="Exclamation" /> 

Now to the interesting part - if, instead of using ```
forms.sections_card.controller.showRecords(formB_to_formA);
``` to get back to the record in form A I use an sql select 

var a = formB_to_formA.recid;
var query = “select records from formA where recid = '”+a+“'”;
var maxRows = 1;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxRows);
formA.controller.loadRecords(dataset);


the records in the tab panel ARE loaded correctly <img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /> 

I use similar routines in many other places in my solution and yet only in this one instance do I have this problem - does anyone have any ideas?

i don’t uderstand youre examples complety
because you are saying:

instead of using:
forms.sections_card.controller.showRecords(formB_to_formA);
you do this:
var a = formB_to_formA.recid;
var query = “select records from formA where recid = '”+a+“'”;
var maxRows = 1;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxRows);
formA.controller.loadRecords(dataset);

and then it works.. But this cind of code doesn’t make any sense because you are loading/showing record on 2 completely different forms (sections_card and formA)

what sections_card is build on the same table as formB?

Or is this a typo in youre example and you mean:

forms.formA.controller.showRecords(formB_to_formA);

what happens if you just do forms.formA.controller.show()?
So not setting a foundset? (this is not preferred, you should always try to set foundsets because then you know for sure what is happening)

Sorry Johan,

Yes, that is a typo.

This is what I should have said:

If I load the record in formA using this method

forms.formA.controller.showRecords(formB_to_formA);

then the subsequent method to load the sub set of related records into the non-related tab (formB) does not work - no records are loaded.

But if I load the record into formA using this method:

var a = formB_to_formA.recid; 
var query = "select records from formA where recid = '"+a+"'"; 
var maxRows = 1; 
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxRows); 
forms.formA.controller.showRecords(dataset);

then the method to load the records into the formB tab works OK.

In both cases the method to find and load the records into formB is the same and triggers correctly as part of an onShow method attached to formB. In debugger mode all methods appear to work correctly, finding the right records to load into formB. However when the method to load the records into formB is triggered after the first example no records actually appear in the formB list (the loadRecords step executes but no records actually load, despite being listed in the relevant dataset) whereas when exactly the same method is triggered after the second example they do!

The ONLY difference is the way in which the record that the formB records are related to is loaded back into formA.

Sorry if this is still unclear - the explanation of what is happening only just makes sense to me.

i need to see this in a solution, ther are to many variables.

Johan,

I have cured this by re-creating the form and deleting the old version. No other changes made and now it all works as expected - so I don’t really understand why the problem surfaced in the first place :?

Can forms become corrupt or is there another explanation as to why creating a new version with the same functions works OK while the previous version did not? - just curious!

forms can’t be get corrupted. There has to be something different at one place.

What you can do if this happens again. is not delete the old one but just make a new one with another name. and then really compare it (or give me the solution)

OK - I’ll keep that in mind - thanks for the help