Relational Database Collections Not Connecting to User

Good Evening and thank you for taking the time to take a look at my request.

In short, I would like to have my users complete forms (which I have made into various collections) that are associated with that one particular user.

Hypothetically speaking:

  • Susan is my app user and she’s completed the sign up process and created her account.
  • First, she must complete survey one (Collection A) and it should be linked to her user account.
  • Second she must complete survey two (Collection B) and it should also be linked to her user account.

I would like this concept to apply to all of my users. So on the backend when I search for Susan or any of my users I will get their user details but also survey one and two specific to that said user.

I attempted to make the relationship from the user collection to Collection A and B. I’ve tried one to many, many to one, and many to many however when the record is created it doesn’t associate itself with the user who is creating it. Each time I attempt to add an automatic field it does not allow me to only select “Logged In User”

Any feedback is much appreciated.

Hi @The_Gentleman ,

Can you take screenshots of your collection A and users collection ?

Also when you do action create to collection A.

I suspect that you didn’t fill relationship property when create collection A record. But let’s see the screenshot first.

@Yongki

Thank you for taking the time to help out.

Attached are two separate screen shots. One is a list of the storyboard as well as the process as to how the user accesses and creates survey A & B. I understand it is missing the relationship with the user and that is where I find the challenge.

The second screen shot is the database set up with the three collections the Users, Survey A and Survey B.

Thank you again.

Can you show those collection’s property ?

So, we can check the relationships.

For form, you need to click add automatic field and fill the related property to logged in user.

Here are the collections for User and Survey A.

I have not established a relationship yet. That is where I am having the trouble.

Hi @The_Gentleman ,

You need to have relationship from survey a collection to users.

https://help.adalo.com/database/collections-in-a-database

then you can update that relationship in form using add automatic field.

@Yongki Thanks for your reply.

I shared earlier that I didn’t have the connect because I’m unsure of what relationship would accommodate what I am looking for. Any thoughts?

Thanks again for working on this with me.

relational
Screen Shot 2021-04-23 at 8.16.56 AM

Consider jobs in the example as Survey A collection

@Yongki thanks for all your help.

I’ll take a stab at this and let you know my results.

Thanks again!

@Yongki I did as you instructed.

However once the user has completed the form, I’d like the user to be able to see the for they just submitted in order to edit or simply view. When I add a custom list, the list only displays all of the submissions submitted but all users rather than displaying the submission specific to the user who is logged in.

Any ideas?

In that custom list, use filter logged in user > request.

If you still cannot do it, I need to see if your relationships are correct and your setting in that custom list.

Solving things like this requiring visualization.

@Yongki

That worked! One piece I did not mention was that is a two sided app.

How would I get the admin to view the records. When I try the filter current user survey A it does not work.

Thank you.

Hi @The_Gentleman ,

Great, multi-sided use the same logic too.

For admin, don’t use filter, as they can see other records.
Unless you have leveled admin that assigned for specific areas.

Without screenshots, I am shooting in the dark. :grinning:

@Yongki Im putting something together for you review!

I’ll have it within the hour! Thanks so much!

@Yongki

Here are a few screen shots to help provide a better understanding. In this case the user has already signed up, and they are adding their employment. When the user selects the “add employer” or next button the record should be saved to that users profile.

The second screen shot displays the admin side where all users are listed from the Admin View. The final screen shot displays the detail view of the user and there is a custom list that should display as selected Current User → Employers.

When I look at the employers database collection, it does not associate the user that created the Employer therefore the custom list of employers in the detail views do not work.

I hope the screenshots shed some light.



Hi @The_Gentleman

Can you show relationships too, in collection editor ?

Assuming you have done correctly, there must be a screen to select employer first, or a component (such as dropdown) to indicate that this employer belongs to this current user.

Settings in Adalo are all over the place, it is easy to get lost, but as a guidance, there usually be a screen that are in higher level first, then in the next screen we can use that current higher to save as relationship. The logic would require a precursor to work.

Hi @Yongki

What’d I’d like to happen is the user creates a new employer and it’s automatically connected to that user.

Also the included photo displays the relationship for users and employers.

If your workflow is like that, you can present another screen for the user to choose, such as screen List Employer, if no available employer to choose, you can provide action button that link to another screen, you can use form and in the add automatic field, fill with the current user.

@Yongki I think I got it!

I’m running a few test now. Thanks again!

Michael

1 Like