I am looking at creating a set of permission roles based on groups and then filtering the data they see from the datasources based on those role specifics, but I cannot seem to get it to go forward as I would like.
To get proof of concept I am only trying to filter down a roster datasource and have the following server-side script:
function roleCheckAgents(user)
{
var userRoles = app.getActiveUserRoles();
var query = app.models.Agents.newQuery();
if(userRoles.indexOf(app.roles.testRole) >= 1){
if(app.models.Agents.getRecords().filter().
query.filters.strRelatedCompany._equals === "sampleCompany");
return query.run();
}
}
the group itself has mine and a few other emails in it, and is listed as testRole. In the Agents datasource security, I have Load listed as script with: roleCheckAgents(user).
Realistically, I would like to set multiple filters within one role, e.g. Company === "sampleCompany" && Site === "sampleSite", etc.
Any help would be greatly appreciated as I currently can't see how this will function the way I need/want.
Thank you!
Update:
I was able to get the multiple filters to work, but only as a query script of the datasource. The problem that created is that I already had query builder conditions within the section and you can only have query builder or query script.
Query Script works as follows:
var query = app.models.Audits.newQuery();
if(app.getActiveUserRoles().indexOf(app.roles.Test) > -1)
{ query.filters.field1._contains = "center";
query.filters.field2._contains = "status";
return query.run();}
else
{}
The current query builder items were:
field1 contains? :searchText OR
field2 contains? :searchText OR
field3 contains? :searchText OR
field4 contains? :searchText OR
field5 contains? :searchText
Any thoughts on how to have both as part of either the query builder or the query script?
Thank you. Kristopher