Set linked field

If I want to filter all dashboards to only show items linked to the currently logged on user, is there a reliable way of doing so? I created the many to one relationship to the User, and is able to select the user on creation. However, it will be good if I could default the field to the current user, allowing me to filter out only items related to them later on.

Apologies if this is something I missed in the documentation or quick tutorials.

If your query is in a datasource, use :session$userId parameter as explained here. For example:


select e from sample$Foo e where e.user.id = :session$userId

In a query, executed via DataManager or EntityManager, specify an arbitrary parameter in the query and set its value obtaining it from the user session. For example:


@Inject 
private UserSessionSource uss;

public void foo() {
    ...
    query.setParameter("userId", uss.getUserSession().getUser().getId());

Perfect! Thank you.