Setting ownerId in CRM Blueprint

Good Day

I am busy using the CRM App Templet to build my app and I see that all DataTables automatically get a column assigned called “ownerId”. For example I see that when a User is created the objectId is copied to the ownerId, I like this function and would like to make use of this, but I cannot find the function that governs this process.

For example lets say I create a data table called “Cars” which will list all the cars of all the users, I will use the current user objectId as the ownerId of each vehicle, so when the user wants a list of his cars then the UI will search and show only the cars with the same ownerId and the current User objectId.

I have two questions; Firstly which codeless logic will I use to set ownerId as the current User object Id, and second what codeless logic will I use to fetch all the objects with the same OwnerId as the current User.

Thank you in advance for your assistance.

Kind Regards
Donovan

Hello @Donovan_Hardwick!

I think that using relations is more appropriate for your problem. Especially since the ownerId column is already assigned. You would need to create two tables Cars and Customers, for example. The Customers table will have a cars column related to the Cars table. This way you can easily add new data and get only the values you need.

Regards,
Alexander

Hi @Alexander_Pavelko

Thank you for your advice, creating a relation would probably be the best way to go. However, I would still like to know more about the ownerId as these columns are created automatically and with the User database assigned automatically . I cannot find any logic that governs this I would like to hear from the developers how this system works, from there I can make an educated decision on which option will be the best way forward.

Kind Regards
Donovan

Hi @Donovan_Hardwick ,

The logic for ownerId assignment is pretty simple - it takes ID of currently logged in user and put it in ownerId column. There is no way to change this behavior.

Regards, Andriy

Good Day @Andriy_Konoz

It now makes sense why I couldn’t find any logic for this. Now how can get this to happen to all data tables and not just the Users Data Table?

Kind Regards

Hello @Donovan_Hardwick,

The ownerId field is filled when the Backendless user is logged in and creates a new record in table.

Regards,
Olha