Good Day
I have a User (employees), Company (1to1 Relation to User) and Customer (1 to many Relation to Company) table, just to be clear Customer table is a child of Company and Company is a child of User. When a user creates another user I want to get the Company of the current user and and add a relation to the user being created, this will allow employees to all be linked to their company. What codeless logic can I use to retrieve this information?
I would also like to know how do I display a list of customers which is linked to current User’s Company, for example lets say the current User has a relation to the Company “A” which in return has a relation to Customer “1” “2” “3”. How will I be able to get the Customer “1” “2” “3” information into a table using codeless logic?
Kind Regards
Hello @Donovan_Hardwick
Your schema is not clear to me because there are some inconsistencies in your description.
Company to User, Customer to Company → User don’t have any relations.
That’s why it is not clear to me how to do this “and add a relation to the user being created”.
If you want to add the company of the current user to the user being created, so it is impossible because “Company” has 1 to 1 only if you want re-write
Regards,
Viktor
Good Day @viktor.liablin
My apologies for the confusion the relational map is as follows:
Users → Company → Customer
I other words Users table will have a Company column which will be a relation to the Company table, and Company table will have a Customer column which will be a relation to the Customer table. Hope this clears everything up.
Kind Regards
@Donovan_Hardwick
For your case, you can use “relations depth” property
Logic to get customers and add company to new user based on current user
Good Day @viktor.liablin
Great it works!! So first the current user details are stored in an object, the relations are then extracted and stored in separate objects. I have not thought of this but it will assist me greatly, thank you.
Kind Regards
@viktor.liablin
I forgot to mention, what would the logic be to exact Users who have a relation to company “A”, for example I want to show all the Users that are related to the same Company as the current User Company. This list would be displayed in a table and if I have for example a 1000 users i will need logic that could quickly sort users.
Kind Regards
@Donovan_Hardwick
I made a mistake in the previous example. There you can get no more than 10 customer
Here updated:
I forgot to mention, what would the logic be to exact Users who have a relation to company “A”, for example I want to show all the Users that are related to the same Company as the current User Company.