Open Closed

Organization Unit use case #6223


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Scenario: 3 user exist: "admin1" "admin2" "user1"

"admin1" create some data for "user1". This data get stored in db table "table1". "admin2" also create some data for "user1". This data also get stored in db table "table1".

Now for "user1" there are 2 records in the table "table1".

"user1" login and check the data in web app so user gets 2 records, created by "admin1" and "admin2" "admin1" login and check the data in web app so filter data for "user1" and get only 1 record "admin2" login and check the data in web app so filter data for "user1" and get only 1 record

Question: How we can achive this use case.

My Thought: we can create 2 organization unit. "org1" and "org2". assign "admin1" to "org1" assign "admin2" to "org2" assign "user1" to "org1" and "org2" ABP framework will do some magic (i am not sure if that's the capability) where based on logged-in user org unit data can be filtered out.

Please guide me how i can achive this and what changes has to be done while creating this entity and at the services level for data transaction.

Let me know if you need more clarification.


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think you can easily filter the data by userid.

    "user1" login and check the data in web app so user gets 2 records, created by "admin1" and "admin2"

    query.where(x => x.userid = user1-id)

    "admin1" login and check the data in web app so filter data for "user1" and get only 1 record

    query.where(x => x.userid = user1-id && x.creator-id = admin1-id)

    "admin2" login and check the data in web app so filter data for "user1" and get only 1 record

    query.where(x => x.userid = user1-id && x.creator-id = admin2-id)

    | id | userid | data | creator-id | | --- | --- | --- | --- | | 1 | user1-id | user1-data1 | admin1-id | | 2 | user1-id | user1-data2 | admin2-id |

  • User Avatar
    0
    shobhit created

    Thanks @Maliming.

    Your suggestion for recrods is workable. will do that. But if we have add drop down filter in the "Advance filter" section that will show only values that "admin1" belongs to a "section" like "organization unit". What could be easy solution.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I suggest you create your own organization unit instead of using the identity's organization unit if you prefer it.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15