Announcement

Collapse
No announcement yet.

How to hide a field from the user

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to hide a field from the user

    Good afternoon, dear forum participants. Is it possible to hide (hide) a field (type string) from the user. Do you need it so that the administrator can see, but the manager does not see this field? I mean, show the field by user role.

    Pictures stuck for example

  • #2
    Hi,
    Please try this:
    1. Create the file /client/custom/src/views/account/hide-description-handler.js with the code:
    Code:
    define('custom:views/account/hide-description-handler', ['dynamic-handler', 'views/record/detail'], function (Dep) {
    
        return Dep.extend({
    
            init: function () {
                this.controlFields();
            },
    
            controlFields: function () {
                if (!this.recordView.getUser().isAdmin()) {
                    this.recordView.hideField('description');
                }
            },
        });
    });
    2. Add to the file /custom/Espo/Custom/Resources/metadata/clientDefs/Account.json this code:
    Code:
    "dynamicHandler": "custom:views/account/hide-description-handler"
    3. Administration -> Clear Cache
    4. Refresh a webpage

    Comment


    • #3
      I did it without programming:
      Put the respective field(s) on a panel of its own and make it visible by condition in the layout manager only for team administrator.

      Comment


      • Vok
        Vok commented
        Editing a comment
        Thanks a lot for the advice!

    • #4
      Originally posted by Maximus View Post
      Hi,
      Please try this:
      1. Create the file /client/custom/src/views/account/hide-description-handler.js with the code:
      Code:
      define('custom:views/account/hide-description-handler', ['dynamic-handler', 'views/record/detail'], function (Dep) {
      
      return Dep.extend({
      
      init: function () {
      this.controlFields();
      },
      
      controlFields: function () {
      if (!this.recordView.getUser().isAdmin()) {
      this.recordView.hideField('description');
      }
      },
      });
      });
      2. Add to the file /custom/Espo/Custom/Resources/metadata/clientDefs/Account.json this code:
      Code:
      "dynamicHandler": "custom:views/account/hide-description-handler"
      3. Administration -> Clear Cache
      4. Refresh a webpage
      Thanks a lot for your answer! And you can somehow do that so that the filtering was by role. The logic is this:
      If the user has the "Admin" role, then he sees the field. If not, then he does not see the field.

      Comment


      • #5
        Utilizing a Role is a good idea.
        You don't need to specify any role for Admin as the admin user has no permission restriction at all. You only need to restrict the regular user do not read this field. Open the regular user Role -> Field Scope -> Account -> field 'description' -> Read -> NO.

        Comment


        • #6
          Is there any way for regular user to see field value only on his own profile? For example I want to make salary and vacation fields for employees, but them to be able to see only their own.

          Comment


          • rabii
            rabii commented
            Editing a comment
            you can use layout set they are powerful and would allow you to create / design layouts for each team.

          • sandro
            sandro commented
            Editing a comment
            rabii, I still can't archive it with layoutsets. What I need is something like:
            Role -> Field Scope -> Account -> field 'description' -> Read -> OWN.

        • #7
          Originally posted by sandro View Post
          Is there any way for regular user to see field value only on his own profile? For example I want to make salary and vacation fields for employees, but them to be able to see only their own.
          You can simply add own access to the entity Users in the User Role (screenshot 1). If necessary, hide all extra fields in the same Role (screenshot 2).

          In this way, User A sees only himself in the list of users, and in his own profile he can see absolutely all the fields that you left visible to him (for example, salary and vacation).​
          Attached Files

          Comment


          • sandro
            sandro commented
            Editing a comment
            Yes but then User cant do any assignment (I forgot to mention that they need to see other users) because he dont have access to other users. I managed ito hide field through dynamic handler. Thank you for effort anyway. Cheers
        Working...
        X