Making Master-Detail from existing non-Jam created tables

144 views
Skip to first unread message

Drazen Babic

unread,
Jul 31, 2020, 4:16:02 AM7/31/20
to Jam.py Users Mailing List
Hi everyone, 

I think this was discussed before, but can't find it. 

Typical scenario with two tables ie Entry and EntryDetail, with existing data.

Entry has ID....
EntryDetail has ID, EntryID....

They are plain tables, no Master ID field and Master record id field in EntryDetail.

What are the steps to get this working with existing data?

If we can crack this, it will be beneficial for everyone.

Cheers

D. 

Manos Pappas

unread,
Jul 31, 2020, 4:39:45 AM7/31/20
to Jam.py Users Mailing List
The way I do it is this:
- Put database in manual mode
- Import the Entry table in the Invoices category
- Import the EntryDetail in another (any) category. I create a DetailData category and put it inside that.
- On the EntryDetail properties, select the Master ID field ID.
- Switch the database back to non-manual mode

Drazen Babic

unread,
Jul 31, 2020, 5:36:29 AM7/31/20
to Jam.py Users Mailing List
Thanks Manos

In Sqlite db, Import does not work on current Item Group. But thats ok, we can create a new Group.

Im not sure how can we populate Master ID Record though? For Details we need two more DB fields as I understand, so one is not linked and will be empty.


I think some sql is needed, particularly if we start moving tables from one group to another.
This is because of existing tables and the UX design which is unknown yet.


Cheers

Andrew Yushev

unread,
Jul 31, 2020, 2:54:33 PM7/31/20
to Drazen Babic, Jam.py Users Mailing List
Hello,
 
Create a group with detail type.
Import detail here and set the Master record id field.
Import master to another group with item type.
Add the detail by clicking on the Details button.

Regards,
Andrew Yushev



пт, 31 июл. 2020 г. в 12:36, Drazen Babic <bab...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/39d764a2-137e-4c38-9632-687ec8e34ee2o%40googlegroups.com.

Drazen Babic

unread,
Aug 1, 2020, 9:47:52 AM8/1/20
to Jam.py Users Mailing List
Thanks Andrew, 

there are a couple of problems with this approach though:

- we do not know what Master ID field is in Details Table? It exist in Demo Details, so what are the consequences of not having it? It is not possible to set this after the Import.

- since we can't Import in Details Group when there are common fields, what is the consequence of not having Primary key field, Master ID field, Master record id field and Deleted flag, on Table Group Editor? Again, it is not possible to set this after the Import.

Other than that it works beautifully! 

Cheers 

Andrew Yushev

unread,
Aug 1, 2020, 4:20:19 PM8/1/20
to Drazen Babic, Jam.py Users Mailing List
Hello,

For imported tables there is no need to add the Master ID field.
Without it you can add the table as detail to only one master.

For Groups, if you do not specify these fields in the group, you must  
specify them for each item.

Regards,
Andrew Yushev

сб, 1 авг. 2020 г. в 16:47, Drazen Babic <bab...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.

Drazen Babic

unread,
Aug 3, 2020, 4:26:24 AM8/3/20
to Jam.py Users Mailing List
Hi,

my comments below.

Cheers



On Sunday, August 2, 2020 at 4:20:19 AM UTC+8, Andrew Yushev wrote:
Hello,

For imported tables there is no need to add the Master ID field.
Without it you can add the table as detail to only one master.

than this is not great because we might need the same detail on a few masters. 
 

For Groups, if you do not specify these fields in the group, you must  
specify them for each item.

as seen above "Again, it is not possible to set this after the Import." :)

The Detail Group must be empty to be able to do so. And if not empty, we can't Import. So catch 22!
 

Regards,
Andrew Yushev

сб, 1 авг. 2020 г. в 16:47, Drazen Babic <bab...@gmail.com>:
Thanks Andrew, 

there are a couple of problems with this approach though:

- we do not know what Master ID field is in Details Table? It exist in Demo Details, so what are the consequences of not having it? It is not possible to set this after the Import.

- since we can't Import in Details Group when there are common fields, what is the consequence of not having Primary key field, Master ID field, Master record id field and Deleted flag, on Table Group Editor? Again, it is not possible to set this after the Import.

Other than that it works beautifully! 

Cheers 

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam...@googlegroups.com.

Andrew Yushev

unread,
Aug 3, 2020, 4:36:26 AM8/3/20
to Drazen Babic, Jam.py Users Mailing List
Hello,

than this is not great because we might need the same detail on a few masters. 

Unfortunately, it is the only way possible.

The Detail Group must be empty to be able to do so. And if not empty, we can't Import. So catch 22!

I'll try to come up with something.

Regards

пн, 3 авг. 2020 г. в 11:26, Drazen Babic <bab...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/4c78ee8c-76d6-4148-bdc5-3cab4092f33co%40googlegroups.com.

Andrew Yushev

unread,
Aug 3, 2020, 5:28:22 AM8/3/20
to Drazen Babic, Jam.py Users Mailing List
Btw, if you have some complex relations in the imported database you can do as follows:

пн, 3 авг. 2020 г. в 11:36, Andrew Yushev <yush...@gmail.com>:

Drazen D. Babic

unread,
Jan 12, 2021, 3:21:30 AM1/12/21
to Jam.py Users Mailing List
Hi Andrew, 

I think this needs a little explanation :)

The problem with linking Master-Detail is that Master_rec_id is empty for Imported tables. Hence, below is not true from the link provided:

"Since the invoicetable is a detail it has the master_rec_id field that stores a reference to invoice that has this record, we can show the user an invoice that contains the current sold record. To do so we pass to the create_table method the function that will be executed when user double click the record:"

That Jam functionality is missing with no master_rec_id I'm afraid. 

How to solve this issue?

Thanks

Andrew Yushev

unread,
Jan 12, 2021, 2:52:36 PM1/12/21
to Drazen D. Babic, Jam.py Users Mailing List
Hi,

You must set the master_rec_id attribute of the table.
You must select a field from a list of available fields.
For example if detail table have a field invoice_id that store master record primary field,
you select this field.

Regards,
Andrew Yushev


вт, 12 янв. 2021 г. в 11:21, Drazen D. Babic <bab...@gmail.com>:

Drazen D. Babic

unread,
Jan 13, 2021, 1:05:12 AM1/13/21
to Jam.py Users Mailing List
Excellent!

Thank you, all works now.

For the readers, the Master-Detail in my scenario is displaying content of 3 tables, just like Tracks.js displaying Invoice table with the sold Item we double-click.

However, the Demo Track.js has master_rec_id in the code, which is a field in the Invoice table in Details Group. Infact, Details Group is forcing user to specify "Master record id field" and "Master ID field" in Jam v5.

And this is the confusion since there are no such a fields when the tables are Imported. So instead of using master_rec_id in this code:

function show_invoice(invoice_table) {
    var invoices = task.invoices.copy();
    invoices.set_where({id: invoice_table.master_rec_id.value});

we would use for example:

function show_cheque(entrydetail) {
    var entry = task.entry.copy();
    entry.set_where({id: entrydetail.entryid.value});

The entryid was the missing link in my scenario. 
To make it easier, tables:
Entry(id,...)
EntryDetail(id,  EntryId, ChequeId,....)
Cheque (id, ...)

So now I can identify exactly on which Entry record there is an cheque without thinking of master_rec_id and master_id

Enjoy
Reply all
Reply to author
Forward
0 new messages