Local Storage creation is automatically adding a new field tenant_id

Local Storage creation is automatically adding a new field tenant_id

  

Hi all,


I tried to create a new local entity in the mobile app. But somehow a new field (Tenant_Id) is added in the column as shown in the screenshot below:


That Tenant_Id field is hidden in the Service Studio.


The problem is all queries now become invalid. In the aggregate with filter LocalInspectionScore.AuditId = AuditId, I've got the following result:


If I compare it with the Web SQL, the values above should be as follows:

Tenant_Id : 4 --> 0

Id: 331 --> 4

AuditId: 2425 --> 331

PassFailResponseId: 7 --> 2425

Value: 1 --> 7

IsActive: true


I don't understand why the values were shifted. Does anyone know how to solve this issue?


Regards,

Kadek

Hello Kadec,

Is your application Multi-tenant? Check the eSpace "is Multi-tenant " property. 

IG

Hi IG,


Thanks for your reply.

Yes we're implementing the multi-tenancy in the app, so all eSpaces are marked as Multi-tenant including the mobile app.

Or should we just set that only on backend or entities eSpaces?


Regards,

Kadek

Hi Kadec,


You can have multiple approaches for your MT implementation. Did you get a chance to read this how-to?


If you're getting distinct results from runtime to testing aggregates/Queries, it's most likely due the tenant id not being the same. You can set the tenant for testing purposes by going to "Module->Configure Tenant to Test Queries..."


IG

Solution

Hi IG,


Thanks for your reply, But I believe the Local Storage Entities cannot be tested because the data will be stored in the mobile devices not in the OS platform.


Actually we have implemented the multitenancy in our backend entities. It works fine when we create the local entity from database (as you may know there are two options to create local entity: Add Entity and Add Entity from Database). However it will be an issue when we create a new local entity that is not exist in the database (choose option 1: Add Entity).


I found a solution myself:

  1. Create new Entity in backend eSpace (e.g. InspectionScore).
  2. Publish and Refresh the references from mobile app eSpace.
  3. Create new local entity from database, select the InspectionScore.
  4. At this point the LocalInspectionScore entity will be created in our local storage. I can guarantee there will be no additional Tenant_Id field.
  5. Delete InspectionScore from backend eSpace.
  6. Publish and Refresh the references from mobile app eSpace.
  7. Change the type of Id from InspectionScore Identifier to LocalInspectionScore Identifier.


I haven't tried to set the Multi-Tenat to false in the mobile app though.


Regards,

Kadek

Solution