Hello Community!
I need to read the roles of the user logged in the mobile app. I try with a query sql but I don't have any result (query is working from the sql console). There is any other better option for that?
var sqlText =
"select u.contactid, u.name, rol.name from sysUserInRole ur " +
"inner join sysadminunit u on ur.sysUserId = u.id inner join " +
"sysadminunit rol on ur.SysRoleId = rol.id where u.contactid ='" + Terrasoft.CurrentUserInfo.contactId + "'";
var me = this;
Terrasoft.Sql.DBExecutor.executeSql({
sqls: [sqlText],
success: function(data) {
if (data.length > 0) {
var records = data[0].rows;
for (var i = 0, ln = records.length; i < ln; i++) {
var sqlData = records.item(i);
}
}
}
});
Like
Hello Federico,
And have you tried using ESQ select query using the Terrasoft.CurrentUserInfo.contactId as a value for the ESQ filter? Please try this approach as well.
Best regards,
Oscar
Oscar Dylan,
Can you give me a example of this query using esq for mobile?
Federico Buffa,
I have no example, but the code should be similar to the one below:
var resultArray = [];
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "SysAdminUnitInRole" });
esq.addColumn("SysAdminUnit");
esq.addColumn("SysAdminUnitRole");
esq.filters.addItem(esq.createColumnFilterWithParameter(3, "SysAdminUnit", Terrasoft.CurrentUserInfo.userId));
esq.filters.addItem(esq.createColumnFilterWithParameter(4, "SysAdminUnitRole", Terrasoft.CurrentUserInfo.userId));
esq.getEntityCollection(function (result) {
if (result.success && result.collection.getCount() > 0) {
var item = result.collection.getByIndex(0);
resultArray.push(item.get("SysAdminUnitRole"));
}
}, this);Best regards,
Oscar
Oscar Dylan,
I tried to add the esq query but Im getting error in the filters looks filters not exist in the esq. Im trying to add this in a custom BR. Any idea of the correct syntax?
If I check the esq properties for filters is undefined. As well I tried create a group filter to add it later to the esq but with no luck.

Any another idea of how to know the roles of the user in the mobile app?