Display field only for admin
Collapse
X
-
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:
-
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:
-
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 } } }
regardsLeave a comment:
-
damn I just noticed that you are not able to use formula in this type of condition -
I am just guessing but you can try - Administration->Entity->Field->Condition making field visible-> env\userAttribute('type') == 'admin'Leave a comment:
-
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 } } }
Leave a comment:
-
in custom/resources/metadata i didn't have entiAcl folder i need to create it and add my file ?Leave a comment:
-
You can define a field as adminOnly in metadata > entityAcl: https://docs.espocrm.com/development...ta/entity-acl/Leave a comment:
-
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:
-
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.Last edited by victor; 12-12-2022, 07:15 PM.Leave a comment:
Leave a comment: