Query Returning Limited Result

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
mfauzi
Posts: 41
Joined: Thu Feb 15, 2007 3:00 am

Query Returning Limited Result

Post by mfauzi »

We developed a multi tenant app and the queries need to return the records associated with the login user. Below is the scenario
There are 3 objects
1. SysUser
2. cust
3. AlarmSO
The relation is
AlarmSO(M) ----(1) cust (M)-----(M)SysUser
All the forms which shows the relationship works fine, the issue is the query.
Alarm has 5 records, customer has 3 records and all are link to alarms

I assigned the regularuser to all the 3 customers.
When run the query m it displays only records related to one customer, but what I want is to display the records for all the 3 customers.
Below is the query info

FIND AlarmSO WHERE AlarmSO.pCustomer.ID=LoggedInSysUser.pCust.ID


attached is the the related bsv.
The related query is query Login
mfauzi
Posts: 41
Joined: Thu Feb 15, 2007 3:00 am

Re: Query Returning Limited Result

Post by mfauzi »

I really hope somebody can point to me the right direction on how to display all the alarm as per login user.
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: Query Returning Limited Result

Post by weblike »

Hi,

I don't say your approach is good or not, but I'll write how I deal with this kind of multi tenant apps and it works:

1. I create a BO .."STAFFBO" whit attribute "AccessLevel" of type "Plain Text" containg the choices of access levels ('Administrator', 'CompanyAdmins', 'Operators')
2. Supose I have different companies using the app I make 2 rules in each BO:
First rule:
IF CurrentBO.Company IS UNDEFINED Then CurrentBO.Company=LoggedInSTAFFBO.Company
Second rule:
IF LoggedInSystemUser.AccessLevel<>'Administrator' AND LoggedInSTAFFBO.Company<>CurrentBO.Company Then READ PROTECT CurrentBO FROM CompanyAdmins AND Operators

I words first rule is inserting the Company Name/ID for new records (undefined)
The second rule protects those records from users which are from other company.

Hope this helps,

Excelent day sir!!!
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
mfauzi
Posts: 41
Joined: Thu Feb 15, 2007 3:00 am

Re: Query Returning Limited Result

Post by mfauzi »

I think I need to clarify further of my requirement.
1. a logged in user can view more than 1 one customer alarm. This is the M-M relationship.
2. The user-cust assigment is determine by the administrator.
3. Each use can have multiple role . This is shown in sysuser. Currently I still create the field admin, user etc in the SysUser object.
mfauzi
Posts: 41
Joined: Thu Feb 15, 2007 3:00 am

Re: Query Returning Limited Result

Post by mfauzi »

Any suggestion guys. I just cannot fs or igure out this problem Is it a bug?
mfauzi
Posts: 41
Joined: Thu Feb 15, 2007 3:00 am

Re: Query Returning Limited Result

Post by mfauzi »

Just to share, I was able to solve this issue with Valdimir help.
below is the query used.

FIND AlarmSO WHERE AlarmSO.pCustomer IN LoggedInSysUser.pCust
Post Reply