Rochelle Valdez
Rochelle Valdez

Reputation: 11

Appmaker: Only render filtered results on table load

I have a table of customers, with a column 'account owner', with which I'd like to filter the table of displayed customers so that only the customers assigned to a particular owner will be rendered. When an account owner signs in to the app, the app will detect the active user, find all customers with 'account owner' === active user and list those customers.

So far I've got this code on the page containing the table 'onAttach':

var datasource = widget.datasource;
datasource.query.filters.accountOwner._equals = app.user.username;
datasource.load();

It works for now, but I'd like to know if there was a better way to filter a table onLoad.

Upvotes: 0

Views: 569

Answers (1)

Markus Malessa
Markus Malessa

Reputation: 1831

There are a couple additional options.

  1. Set your filter in your model datasources inside your query script. This will be much more secure since it runs on the server instead of the client, like this:
query.filters.accountOwner._equals = Session.getActiveUser().getEmail();

return query.run();
  1. In your model security, select the Advanced check box, under the Load option select Owner or Roles from the dropdown and then select your field that contains your owner email address.

Upvotes: 2

Related Questions