Default values for relationships

It seems to be impossible to set default values for a relationship.
I have the following simple scenario:
A user has a relation to the collection ROLE which just holds three values:

  • Client
  • Doctor
  • Administrator

I want to set the default user role “Client” during or directly after the signup of a new user.
It works setting the role via a form. But I need to do it in the background.
I don’t get this to work. Any help would be highly appreciated.

You can set fields of a form automatically in the background.
Try this, I think this could solve your problem

In my case, instead of creating a separate collection for user’s role, I instead just add a field in Users Collection named “User Type”. I can fill that User Type with a text such as doctor, client, administrator.

Let say later on we want to create 2 buttons that is 1 button will show only to the user with User Type doctor, and the other will show only to the user with User Type client.

then we can simply filter our users with :

  • column User Type contains someKeyword (for example doctor)

We can play with visibility, filter, or conditional actions.

Also you can set automatic field when user sign up for adding those User Type field.

@projectlinuxsupports: I tried this already and I can set a “hardcoded” default value for an invisible text field. But this is kind of ugly. These are only workarounds, but no easy way to control the available values in a lookup list. A pretty basic requirement from my PoV.

2 Likes

Agreed, this is going to be a popular feature request. The proper way to handle this is with a separate table and the ability to assign the automatic field value to a foreign key in that table (in your case, the role table). Please add your vote here as others have already identified the need for this feature: https://adalo.canny.io/feature-requests/p/set-automatic-relationship-field-values

How about have an invisible dropdown menu on the sign up page, set the default to be Client, and on the signup button field, after signing up the user, add an update action>logged in user> role > form input > the invisible dropdown menu.

@karimoo This tutorial walks you through how to do it: https://help.adalo.com/how-to/form-status

This process does not seem to work for signing a user up and updating the database with a default status.

It should work fine. Can you post some screenshots how you have set it up?