Role lookup to identify which SQL query to run

Perspective Ignition v8.1.2

I am trying to identify what “role” a user is logged in based on their security. This will identify which query will populate a table of data.

For example “USER ABC” is setup as a role of “Customer”, along with 59 other users in that role.
If one of the “Customer” roles is logged in, then a select query will only show that customer data in the table, or “USER ABC” will see their data, no other data.
Anyone else can see all data using a select * query.

I have a parameter setup to identify the actual customer name and pass it to the query (this works), but the script for “if role = customer, run xyz query” else “abc query” is not working.

I may be going about this wrong but I’m using an expression binding for the table data and a script transform using the following script: The company_name, role and user_name are setup as parameters for the page.

path1 = "AllBatchJobs/GetAllBatchJobs"
path2 = "AllBatchJobs/SpecificCustomerData"
if view.params.role == ("customer")
Params = {
		"company_name": view.params.company_name
		}
system.db.runNamedQuery(path2, Params)
else 
system.db.runNamedQuery(path1)

Welcome @rcrenner24, could you post your script for:

Could you also state whether you are using Perspective or Vision (just in case it’s significant :slight_smile:)?

Yes of course. I should have included that. Thanks.

Thank you :slight_smile:

Which part exactly is not working. For example, does the else statement always get triggered? If so, is your role Customer or customer (case is important)?