Home » Developer & Programmer » Forms » Master-detail relationship on 2 tabs : coordination problem
Master-detail relationship on 2 tabs : coordination problem [message #299523] Tue, 12 February 2008 05:38 Go to next message
wyatt
Messages: 4
Registered: February 2008
Junior Member
Hello all !

I have two tabs.
The first contains the master block.
The second contains the details block (multi-rows).
The master-detail relationship has been created with the wizzard.
When i browse the master records in the first tab, the details records populate accordingly in the second tab, so it works well.

My issue is : when i add a new record in the master block (with CREATE_RECORD), save it (with COMMIT_FORM) and click on the second tab to insert detail records, i see that the detail block is not correctly refreshed : it is empty except of one record and one field (the foreign key) wich still contain an old value. When i click on this field, the value is replaced by the good one (the primary key of the master record).

No big issue but i think it is confusing for the user to see the value 'A' in the detail block whereas he just added the record 'B' in the master block.

Note : if after the COMMIT_FORM i do a GO_BLOCK('detail'), then the detail block is correctly refreshed. But i don't want to go to this block just after the commit. It is the user who decides to go to this block by clicking on the second tab. And data must be correctly refreshed at that time.

[Updated on: Tue, 12 February 2008 05:39]

Report message to a moderator

Re: Master-detail relationship on 2 tabs : coordination problem [message #299591 is a reply to message #299523] Tue, 12 February 2008 10:00 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
You can use a When-Tab-Page-Changed trigger to go to the first item in the detail block. You may need to check the tab page name to do so.

By
Vamsi

[Updated on: Tue, 12 February 2008 10:01]

Report message to a moderator

Re: Master-detail relationship on 2 tabs : coordination problem [message #299693 is a reply to message #299523] Tue, 12 February 2008 23:48 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Why do you have a 'create_record' on the 'master' block? What is wrong with the default logic? The 'create_record' should be on the 'detail' block.

David
Re: Master-detail relationship on 2 tabs : coordination problem [message #299745 is a reply to message #299523] Wed, 13 February 2008 01:43 Go to previous messageGo to next message
wyatt
Messages: 4
Registered: February 2008
Junior Member
First, thank you for your replies Smile

vamsi kasina wrote on Tue, 12 February 2008 17:00
You can use a When-Tab-Page-Changed trigger to go to the first item in the detail block. You may need to check the tab page name to do so.


Yes i had this idea too and it will work. But... shouldn't Forms handle this itself ?

djmartin wrote on Wed, 13 February 2008 06:48
Why do you have a 'create_record' on the 'master' block? What is wrong with the default logic? The 'create_record' should be on the 'detail' block.


In the first tab, which contains the 'master' block, i placed a "+" button, which triggers a CREATE_RECORD, so the user can insert a record.
The user can also go to the "last record + 1" to insert a new record, but this doesn't change anything to the "problem".
When the user is okay with its 'master' records, then he go to the second tab which contains the 'detail' block, to insert the 'detail' records. And there will be indeed another "+" button with CREATE_RECORD.

I wish to keep it as simple and native as possible, as often advised here. What is the default logic you mentioned ?
Thanks again !
Re: Master-detail relationship on 2 tabs : coordination problem [message #299950 is a reply to message #299745] Wed, 13 February 2008 18:43 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You ARE using the default logic when you go to the "last record + 1" to insert a new record.

Put a 'When-Create-Record' on the 'detail' block. It will be fired when you navigate from the 'master' block to the 'detail' block and no records are retrieved by the builtin query. This saves the user having to press the '+' button on the 'detail' block. It will also populate the 'detail' block with the new key values.

David
Re: Master-detail relationship on 2 tabs : coordination problem [message #300179 is a reply to message #299950] Thu, 14 February 2008 08:52 Go to previous messageGo to next message
wyatt
Messages: 4
Registered: February 2008
Junior Member
Perhaps i missed something, but what do i have to write in this 'When-Create_Record' trigger ?

I created it anyway, with a simple MESSAGE() coded inside just to test it. Unfortunately, it is not triggered when navigating from the 'master' block to the 'detail block' in the other tab.

Note that when pressing the "+" button (CREATE_RECORD) in the 'detail' block, it populates the block with the right key value.

It's not a very big issue (mainly a refreshing problem i think), but i would just like to understand. Thanks for your help and patience !
Re: Master-detail relationship on 2 tabs : coordination problem [message #300713 is a reply to message #300179] Sun, 17 February 2008 22:46 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Put the code that you currntly have in the '+' button trigger into the 'when-create-record', and in the '+' button trigger just have a 'Create_Record' command.

I assume you have the triggers on the correct block.

David
Re: Master-detail relationship on 2 tabs : coordination problem [message #301081 is a reply to message #300713] Tue, 19 February 2008 02:56 Go to previous messageGo to next message
wyatt
Messages: 4
Registered: February 2008
Junior Member
Well, both "+" buttons just do a CREATE_RECORD on their respective block.

WHEN-TAB-PAGE-CHANGED and MESSAGE(:SYSTEM.CURSOR_BLOCK) show me that the navigation stays on the 'master' block, even if i switch between tabs.
When i just click on the 'detail' block, it refreshes correctly.
Navigating to the detail block with a GO_BLOCK in the WHEN-TAB-PAGE-CHANGED is the only solution i see so far.


Re: Master-detail relationship on 2 tabs : coordination problem [message #301264 is a reply to message #301081] Tue, 19 February 2008 22:09 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Well, 'Yes'. You DO have to navigate to the block before its triggers can fire.

David
Previous Topic: sequences
Next Topic: Webutil problem
Goto Forum:
  


Current Time: Sat Dec 03 16:26:04 CST 2016

Total time taken to generate the page: 0.07504 seconds