Announcement

Collapse
No announcement yet.

Display field only for admin

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

  • yberges
    replied
    radek 1000 thanks ! solved

    Leave a comment:


  • radek
    replied
    There is another simpler solution.

    While yes you can use dynamic logic to hide the field depending on team this will actually not hide it from API.

    Assuming your goal is that only admin/specific role can see the field you can go to:

    Administration > Roles > Select/create role for non admin user > scroll down to field scopes > select entity and click the (+) > select field you want to make admin only > set read to no

    Any user with this role will not be able to see the field, while admin user (or other Roles where read=yes) will be able to see it.

    Disallowing read will also automatically hide the field from layout so you do not need to set additional dynamic logic.

    Leave a comment:


  • yuri
    replied
    This is back-end only. It won't hide the field in the frontend. You can utilize a dynamic logic to hide the field from frontend.

    Leave a comment:


  • yberges
    replied
    hello i try it but strange that doesn't works
    my entity name Etablisssement
    url : /custom/Espo/Custom/Resources/metadata/entityAcl/Etablissement.json
    this is my code
    Code:
    {
        "fields": {
             "informationsPourLeBadge":
                   { "adminOnly": true },
             "codecomptable":
                   { "adminOnly": true }
          }
     }​
    but user (basic) can add a a value in codecomptable field when he create an entity in small panel (edit)
    regards

    Leave a comment:


  • yberges
    replied
    thanks for sharing solution

    Leave a comment:


  • Jakub Grufik
    commented on 's reply
    damn I just noticed that you are not able to use formula in this type of condition

  • Jakub Grufik
    replied
    I am just guessing but you can try - Administration->Entity->Field->Condition making field visible-> env\userAttribute('type') == 'admin'

    Leave a comment:


  • yberges
    replied
    ok cool thanks !

    Leave a comment:


  • rabii
    replied
    yberges

    Yes you need to create this new folder if not exist, do these steps:

    Create a new folder under custom\Espo\Custom\Resources\metadata\entityAcl\yo u_entity.json

    Code:
    {
        "fields": {
             "yourField":
                   { "adminOnly": true }
        },
       "links": {
             "yourLink":
                  { "nonAdminReadOnly": true }
        }
    }
    This should do the job.

    Leave a comment:


  • yberges
    replied
    yuri can you explain more about this intégration ?

    Leave a comment:


  • yberges
    replied
    in custom/resources/metadata i didn't have entiAcl folder i need to create it and add my file ?

    Leave a comment:


  • yuri
    replied
    You can define a field as adminOnly in metadata > entityAcl: https://docs.espocrm.com/development...ta/entity-acl/

    Leave a comment:


  • yberges
    replied
    victori try it but doesn't work field is aleady hidden ...
    => maybe adding css style depend of user ?

    Leave a comment:


  • rabii
    replied
    You can't select a condition like (role=admin) that is not available. you can only set an assigneduser e.g (assignedUser=admin). otherwsie is to create a custom view for your entity and there you can check if the user isAdmin then show the field otherwise hide the file. see example code below:

    Code:
    define('custom:views/your-entity-type/record/detail', ['views/record/detail'], function (Dep) {
      return Dep.extend({
         setup: function () {
                 Dep.prototype.setup.call(this);
                 this.showField('name');
         },
        afterRender: function () {
                Dep.prototype.afterRender.call(this);
    
                if (!this.getUser().isAdmin()) {
                   this.hideField('name');
               }
        },
     });
    });

    Leave a comment:


  • victor
    replied
    Hi yberges,

    Go to Administration -> Entity Manager -> Your_Entity_Name -> Fields -> YOUR_FIELDNAME -> Conditions making field visiblepress -> Edit and select a condition. For example, to make this field visible when Team = Top Management, or Role = Admin. Of course, before that, the field must be displayed on the desired Layout.
    Attached Files
    Last edited by victor; 12-12-2022, 07:15 PM.

    Leave a comment:

Working...
X