Automatic Pre-Population of Company Select Field

I’ve spent time looking through the forum and I’ve seen similar questions and answers but I can’t seem to find the answer that directly addresses my issue. I’m a beginner, so apologies if I’m repeating something that’s already been raised and resolved.

I’m building a multi-tenanted app (one app serves multiple clients). All data tables include a relationship to a “Company table” in order to filter records when displaying, adding and editing.

When I create an “Add Record” screen I need the new record to be updated with the appropriate Company relationship. I know I can set a Table Rule to automatically populate the record with Company on “Save”, however the live form needs a Company selected as reference to be able to filter all other select fields in the form that belong to that Company – e.g. employees, assets, etc. (“Show” – “Show Assets (using the Company field) that are connected to this form’s Company”)

The only way I’ve found that works so far is to include a “Company” select option and filter this field to “Limit to Company Logged-in User is connected to… Users>Company”. This provides a Company select drop-down that only offers the User’s Company to select and all other select fields show only records for that Company.

I’d like to have the Company pre-populated, so the User doesn’t need (or even better) see this option.

Is there a way to pre-fill this select option, or to somehow select the appropriate Company for the form behind the scenes?

Have I missed a function, or is there a better way to set up my databases that will work?

1 Like

@safetyinmind (Neil)-

The best way to do this is through relationships of tables and users; not through pre-populated fields. I’ll play with it a bit and see if I can come up with a video of how to establish the appropriate relationships. However, I am also certain that @tim.young or @Chem could help you out quicker than I. Otherwise, send a ticket to support@tadabase.io and @Chem’s team will help you out.

Hopefully, more to come friend.
Adam

Hi @safetyinmind

No need to apologize for anything, this is a very good question!

You are certainly on the right track with the method you described. This is exactly why that option exists. I do understand the point of your question though and it would be great to expand on this functionality to make this easier for the end-user.

Things do get complicated quickly though. For example, what happens if a User is connected to more than 1 Company? Which Company would be pre-populated?

The easiest path we could take to develop this kind of functionality would be on a Details Page. As a concept, what do you think of this?

While viewing a Details Page for Company A, a form to insert a new record connected to Companies would have the Company connection field pre-populated with Company A.

I believe this is different than what you’re looking for but perhaps a future solution.

Hi @tim.young . Thanks for the reply. In response to your questions:

“What happens if a User is connected to more than 1 Company? Which Company would be pre-populated?”

This would never become an issue – all our clients (Users) are from separate Companies.

“The easiest path we could take to develop this kind of functionality would be on a Details Page. As a concept, what do you think of this?”

I’ve looked at the “Company Details Page” idea, seen in other forum posts. My testing seems to show that a form on the Company Details page still requires a Company select field to be present in order to filter related connections for other select options – e.g. Assets, Employees, etc. I might be doing something wrong?

If you are implying that there is some development work that could improve this, then yes, please!

Some other ideas

Do you think it might be possible (JavaScript?) to force-select the company field for the user? Removing the mechanics of having to click to pull down the Company select field (or whichever on-page switch is used) and then click their Company name, would be 80% of the solution. Ideally this field would also be hidden/invisible on the page.

Is it possible to create some kind of “Global User Variable” that could hold the Company relationship for each User and be called on? Select once, and never again.

Long-term, I feel like there needs to be a formerly-implemented solution to this (I’ll cross-post to Suggestion Box). I was pleased to discover all of the Tadabase functionality that allows filtering on users and fields that make the creation of a multi-tenant app possible, but it does seem a shame that there is a missing final step that would complete this and make it seamless. It may seem like a small issue, but having to select a company every time a form is submitted really disrupts the users experience and feels like something I will be apologising to our clients for in the future.

The only other solution for me is to remove the Company table, copy the entire app for each client, and create multiple access-points for each Company to sign in - a support nightmare – as we will likely be dealing with many (dozens of) small companies.

Neil Campbell

I have also run into this problem and haven’t figured out a solution yet. Following.

Neil-

Here are some ideas/options to consider (I have not tested them out):

Option 1
Reconfigure the app whereby everything starts from a Company details page. Then everything “under” that Company details page will be associated with that company.

Option 2
Connect the User’s table to the table that will have the add record. Then go into the Records Rule of the form and set the Organization field to Connected Value of User’s Org Value.

When the form is saved the org value of the form should be set to the org value of the user.

Again, I caution that I have not sat down and tested either of these options. Just some ideas.

Hope one of them work…
Adam

Hi Adam,

Those are great and thoughtful ideas.

I’ve considered Option 1 (all pages stem from a “Company Selection Page”). It would require an overhaul, which I’m up for, but I suspect it would also impede other functionality (Breadcrumbs? Jump to page?). I’m also not sure if it would allow pages where you need to create parent/child relationships. It feels like overkill for what appears to be a simple, albeit frustrating, problem.

Option 2 doesn’t quite work. It attaches the Company connection after the record is saved. The main issue is that any multi-select fields (dropdowns) on the form require the Company to be selected on the form for the dropdown to reference the correct company’s records from another table. E.g. adding employees to a Department – the form requires a Company field to filter the dropdown to only show the employees for that company.

Moe has promised a solution shortly that will hopefully resolve this, so I’ll wait and see how that looks.

Thanks for taking the time to think about this for me.

Also – we seem to be in the same field (Health and Safety?) I’d be interested in what you’re building. I’ll DM you.

Neil

1 Like