Record creation error !?

Hi,

I have a setup with some inexpected behavior.

The situation is:

A form in a tab panel base on the following relation (companies_t_to _notes_t):
company_tid = company_tid
globals.g_NtsReadingLevel >= read_level_id

The tab panel shows a list of notes for the current company (filtering by reading level of the user).

In the notes list there is a button showing a popup menu to add notes and some other actions.

Selecting the add note choice calls a method on a third form “dlg_notes_edit” that shows in a dialog:

elements.btn_cancel.visible = true;
foundset.clearFoundSet();
controller.newRecord();
company_tid = forms.frm_Main.company_tid;
application.showFormInDialog( forms.dlg_notes_edit, -1, -1, 460, 290, 'Nova nota', false, false, false);

The problem is that I’m not creating any records through the relationship company_t_to_notes_t. But if I don’t allow record creation through the relationship I get an error!

Strangely I managed to avoid this by allowing record creation in the relationship, but this is not expected behaviour.

I can also avoid the issue by moving the popup from the record row to header. Then I have the expected behavior, that is I don’t need to allow record creation in the relationship.

I’m puzzled :(

My first guess is that this is a bug.
Anyone has faced this? Am I wrong?

Best,
Miguel

the “foundset” you are working on is a related foundset, use controller.loadAllRecords to remove a relatedfoundset and place back a normal foundset (non related)

Jan Blok:
the “foundset” you are working on is a related foundset, use controller.loadAllRecords to remove a relatedfoundset and place back a normal foundset (non related)

I’m sure I don’t follow you Jan.

The code:

elements.btn_cancel.visible = true;
foundset.clearFoundSet();
controller.newRecord();
company_tid = forms.frm_Main.company_tid;
application.showFormInDialog( forms.dlg_notes_edit, -1, -1, 460, 290, 'Nova nota', false, false, false);

Is not running on the main form and it is not creating a record through a relation. That fact is very clear when I put the button that triggers the code in the header part. There is no error
Now, why should it raise an error if instead of being placed on the header part the button is placed in the body part?

What am I missing here!?

Best,
Miguel

Your form contains a related foundset, many calls are forwarded via the controller to the foundset, so you are in fact talking to a related foundset.
As told in the previous post, controller.loadAllRecords() removes the related foundset (and shows all records from the form table)

Jan Blok:
Your form contains a related foundset, many calls are forwarded via the controller to the foundset, so you are in fact talking to a related foundset.

Ok.

I was under the impression that for the relation restriction to operate I would have to be working expressly through the relation as in:

The_relation_TO_other_table.newRecord()

Txs for the clarification.
Miguel