How to convert a related table to subitems

I love the idea and view of the subitems in a table. I want to use this in a CRM application where secondary contacts at a company are added as subitems so they are easily viewable from the main table.

I already have a related table of contacts, with the relation being the company name field. Is there a way I can bring that related table into the main table and convert the contacts to subitems?

1 Like

That would be really cool, but for the time being subitems must belong to the same table… You cannot bring subitems from another table.

EDIT: I stand corrected and I learned something new!

1 Like

If I understand you correctly, you have a table with companies and main contacts, and you want to bring in secondary contacts from a separate table.

One way would be to add a button to the secondary table, to copy the entries to the main table. Use the button to populate the parent field with the relevant entry to ensure that the secondaries are entered as sub-items in the correct place.

2 Likes

Hi Piet,

Thanks for the idea. I’ll give it a shot. I have about 600 rows, so I would be clicking a lot of buttons to get all the contacts moved up.

I would also need to be sure not to add the primary contact from the contact table as a sub-contact, which is a bit tricky.

It’s worth a try, though, as it would only be a one-time data-entry effort, and then afterward, the system would be clean.

1 Like

Hello @Dominic_Symons1 ,

Actually, it is not that complicated.

You need one (canvas) button with code that looks something like this:

One of the decisions you need to make is whether you want to put the contact name in the same column as the account name, of leave it blank (it can still be a sub). In my sample code above, I put the contact name in the account column (of the subitem) AND I made a contact column in the main table. In real live, you would do one or the other.

Prerequisite: in your contact table, you need a column with the exact account name (which should be the case if you are using a subtable now (or a ID number, or…).

The secret: in your master table there are two hidden columns when you turn on subitems: the columns are Parent and Subitems. You can use those names in your formula.

Before:

After pressing the button:

If this is a one time deal, you are done, if you are going to use the button later on again, you have to use AddOrModifyRows and add some stuff to prevent duplicating rows, or add some code to delete all subitems you have added to your master table. Make sure to copy your tables (duplicate) before experimenting, so you can copy and paste when things go wrong.

The full 600 contacts take just a few seconds to be added to your main table.

Greetings, Joost

5 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.