Read-only field based on current logged user role

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kacper
    Junior Member
    • Oct 2023
    • 29

    Read-only field based on current logged user role

    HI!
    Is it possible to make entity field read-only only when current logged user role is different from Admin?
    Thank you in advance
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    In v8.1 it will be possible to define dynamic logic based on specific users or user teams. No admin check though.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • kacper
      Junior Member
      • Oct 2023
      • 29

      #3
      Originally posted by yuri
      In v8.1 it will be possible to define dynamic logic based on specific users or user teams. No admin check though.
      Great, when do you plan to release version 8.1?

      Comment


      • yuri
        yuri commented
        Editing a comment
        In ~1.5 months.
    • telecastg
      Active Community Member
      • Jun 2018
      • 907

      #4
      If you don't mind coding, you can use a dynamic handler to set any conditions that you want.

      Comment


      • llen
        llen commented
        Editing a comment
        hi, I have tried using Dynamic Handler , but I am confused about how to retrieve the logged in user role.
    • llen
      Junior Member
      • Dec 2023
      • 11

      #5
      hi, I have tried using Dynamic Handler , but I am confused about how to retrieve the logged in user role. this is my code
      Attached Files

      Comment


      • rabii
        rabii commented
        Editing a comment
        you can check if current user is not admin like below
        !this.recordView.getUser().isAdmin()
    • yuri
      Member
      • Mar 2014
      • 8453

      #6
      > how to retrieve the logged in user role

      Code:
      this.recordsView.getUser().get('type') === 'admin'
      or checking teams:

      Code:
      this.recordsView.getUser().get('teamsIds').includes('someTeamId')
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment


      • llen
        llen commented
        Editing a comment
        I think type is not the role. The role I mean is the role in the role in database table while the type is user level and it is not a role

      • yuri
        yuri commented
        Editing a comment
        Making an assumption from the initial question, kacper meant admin/non-admin. These are not roles, but the type. Checking roles does not make sense from the Espo ACL design point of view. One should never check user roles.
    • kacper
      Junior Member
      • Oct 2023
      • 29

      #7
      Thanks!

      Comment

      • llen
        Junior Member
        • Dec 2023
        • 11

        #8
        I have successfully retrieved the logged in user role, just by adding the role information into the user getRoles() api

        Comment

        Working...