Understanding the logic

Understanding the logic

  
Hello, I am having trouble understanding the customization in Service Studio... For example, I have created two database tables e.g. customers and companies. Now I want user to log in and view all the customers for his company and not the other companies? How can this be achieved ?

edit: let me add I'm on CE license. I am new to this system and don't have a clue as to where to change the list behavior. How are/should users be  related to the companies etc... 

thanks in advance!

Edit 2: I have created a page and dopped my DB entity so it automatically generated the customer listing. How to I add new condition to only show records created by current user ? In my entity I have foreign key - user ID linked with Users table. How do i edit the conditions ?
Hello !
I was trying hard and have some progress, but I'm far from what I need. I have figured out a way how to use session variable to get UserID of currently logged user (Session.UserId). I am also able to display this in the expression what confirms it's okay.
I strugle since yesterday to use this value when saving form. E.g. I've created a table to list my table, and I have the generic Create new record form.
In the Create new record form I tried to set the value of the column that should store record's creator's ID but no success...
My problem is I don't know where to start... I went through most of the how to's but they only give some idea of generic functionalities. 

Please can someone help me understand:
1) How do I insert
Session.UserId value into a new record.
2) How do I list the records where only MyTable
.SessionUserIdSessionUserId

any help is much needed and appreciated. Thanks and regards, Radek

Radek wrote:
Hello, I am having trouble understanding the customization in Service Studio... For example, I have created two database tables e.g. customers and companies. Now I want user to log in and view all the customers for his company and not the other companies? How can this be achieved ?

edit: let me add I'm on CE license. I am new to this system and don't have a clue as to where to change the list behavior. How are/should users be  related to the companies etc... 

thanks in advance!

Edit 2: I have created a page and dopped my DB entity so it automatically generated the customer listing. How to I add new condition to only show records created by current user ? In my entity I have foreign key - user ID linked with Users table. How do i edit the conditions ?
 
 Hi  Radek,

First of all welcome to the OutSystems community!
To relate the user with the company you need to extend the Users entity of the platform. Just create a new entity eg: User_Company.

Now you need to populate this table with the relationships. Users eSpace won't have knowledge of this new entity so you'll need to have a screen on your application to relate each user with the correct company.


When you have this you can now filter the application data by this company identifier. You can set a session variable to hold this value and set it on user's login.
Afterwards you use it as a filter for your queries.
I've built a small application with this example. In the example users without company set can see all information the others only see their copmany and that company's users.
I hope you it helps you.
Don't forget to check our apps and tutorials which can help you a lot.

Cheers,
André