Is it possible to hide or show a button based on the user role in Edit page?
Like
Dear Sri Saranya,
In order to implement such functionality you need to do the following:
1. In the button diff properties bind "enabled" property on the custom attribute, e.g.
2. Add a custom attribute, which would be set to true or false. This is an example of an attribute:
"isSysAdmin": { "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN, "dataValueType": Terrasoft.DataValueType.BOOLEAN, "value": false }
3. During the initialization of the page you call your custom method, which would be checking current user role and set the attribute to false or true if role is valid. Example of the method:
getUserRights: function() { var scope = this; var currentUser = Terrasoft.SysValue.CURRENT_USER.value; var sysAdmins = ConfigurationConstants.SysAdminUnit.Id.SysAdministrators; var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "SysUserInRole" }); esq.addColumn("SysRole"); esq.addColumn("SysUser"); esq.filters.add("SysUser", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "SysUser", currentUser)); esq.filters.add("SysRole", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "SysRole", sysAdmins)); esq.getEntityCollection(function(response) { if (response && response.success) { var result = response.collection; var isSysAdmin = (result.collection.length !== 0); scope.set("isSysAdmin", isSysAdmin); } scope.loadMenu(); }, this); },
Regards,
Anastasia
Thibaut,
The code above is just an example of implementation of the functionality related to the menu items. The error occurs because the loadMenu function doesn't exist in the current context. Please delete scope.loadMenu() from the code above in order to resolve the issue.