How to Show User-Specific Tasks in a Data Grid Sorted by Status?

Hi Anvil community,
I’m building an employee tasks page where a logged-in user can see all their assigned tasks. The tasks are stored in a Data Table with fields like:
Task Name
Description
Status (Not Started, In Progress, Completed)
Due Date
Assignee (username)
What I’m trying to do:
On my page, I’m using a Data Grid with a Repeating Panel, and I want to:
Show all tasks for the currently logged-in user
Display them in a table layout (like Task Name, Description, Status, Due Date)
Sort the tasks so they appear in this order:

  • Not Started
  • In Progress
  • Completed
    What I’ve tried and what’s not working:
    I’ve created a server function get_user() that returns the current session user.
    Another server function get_employee_tasks(username) returns all tasks for that user from the tasks table.

Code Sample:

# this is a formatted code snippet.
# paste your code between 
This is the client code for Employee_tasks.
```   def form_show(self, **event_args):
    """This method is called when the form is shown on the page"""
    current_user = anvil.server.call('get_user')
    print(current_user)

This is the server code:

def user_login(username, password):
  #Authenitcates a user by comparing the entered username and password to the stored credentials in the data table
  
  #get the user record from the 'users' table
  #app_tables is a data table function in Anvil, which stores the user credentials in this case
  user = app_tables.users.get(username=username) 
  #Validate the password and return the user role if login is successful
  if user and user['password'] == password:
    return user['role']
  #return False if authentication fails
  return False

@anvil.server.callable
def vet():
    user = anvil.server.session.get('user', None)

  if user is None:
    return None

  role = user['role']


  if role == 'admin':
    return 'Admin_Dashboard'
  elif role == 'employee':
    return 'Employee_Dashboard'
  else:
    return None

@anvil.server.callable
def get_employee_tasks(username):
  return app_tables.tasks.search(Assignee=username)

@anvil.server.callable
def get_user():
  return anvil.server.session.get('user', None)```

In what way(s) are these not working?

If the tasks are not being sorted, see “Sorting and slicing” in Searching (querying) a Table.

the output is none and I am also not quite sure on how to get the tasks from the data tables displayed for this specific user.

You’re getting no output because you’re trying to read 'user' from the session dictionary, but you never put anything in session['user']. That key is unset, so your code returns nothing.

Additionally, you’re comparing a plain string to the password stored in your data table. That kind of DIY authentication—checking raw strings client‑side—is highly insecure unless you really know what you’re doing.

will I still be able to show user-specific tasks in the data grid without using the users service?

You should use the user service indeed, instead of making up your own user authentication, password check and session management.

The code you are showing doesn’t use the user service at all.

Perhaps you should have a look at this: Anvil | Add the users service

1 Like