Why is this not working? I am genuinely confuse.
Setting visibility using ESQ is not working. Am I missing something?
define("OpportunitySectionV2", ["ConfigurationConstants"], function(ConfigurationConstants) {
return {
entitySchemaName: "Opportunity",
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
attributes: {
"isSysAdmin": {
dataValueType: Terrasoft.DataValueType.BOOLEAN,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
value: false
}
},
diff: /**SCHEMA_DIFF*/[
{
"operation": "merge",
"name": "DataGridActiveRowDeleteAction",
"values": {
"visible": {
"bindTo": "isSysAdmin"
}
}
}
]/**SCHEMA_DIFF*/,
methods: {
onGridDataLoaded: function() {
this.callParent(arguments);
this.getUserRights();
},
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);
debugger;
scope.set("isSysAdmin", isSysAdmin);
}
}, this);
},
}
};
});
Thank you.
Solem A.