I am trying to get the current user role in mobile but it is not working !
Terrasoft.sdk.Model.addBusinessRule("Activity", {
name: "GetRoleFromtheUser",
ruleType: Terrasoft.RuleTypes.Custom,
triggeredByColumns: ["UsrVisitType","UsrTypeDeVisiteManager"],
events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
executeFn: function(record, rule, column, customData, callbackConfig) {
var myrecord = record;
var currentUser =Terrasoft.CurrentUserInfo.userId;
var store = Ext.create('Terrasoft.store.BaseStore', {
model: 'SMVwUserRoles'
});
var queryConfig = Ext.create('Terrasoft.QueryConfig', {
columns: ['SMId', 'SMUserName', 'SMRoleName'],
modelName: 'SMVwUserRoles'
});
store.loadPage(1, {
queryConfig: queryConfig,
filters: Ext.create('Terrasoft.Filter', {
property: 'SMId',
value: currentUser
}),
callback: function(records, operation, success) {
var loadedRecord = records[0];
if (loadedRecord) {
var role = loadedRecord.get('SMRoleName');
if (role=='Sales Management') {
record.changeProperty("UsrVisitType", {
hidden: true,
readOnly: true
});
}else{
record.changeProperty("UsrTypeDeVisiteManager", {
hidden: true
});
}
}
},
});
Ext.callback(callbackConfig.success, callbackConfig.scope, [hidden,readOnly]);
}
});
Any idea please ?