Is there a way to bypass multitenancy in read actions?

For instance, if multitenancy is set up based on company, but there’s a scenario where an employee belongs to multiple companies. While tasks are managed by applying multitenancy, there might be a specific page where an employee wants to view all of their tasks across multiple companies. Using global? true doesn’t enforce tenancy in all cases, which is not ideal. In Ecto, it was possible to bypass this by specifying a certain option like :skip_tenant , but I haven’t found a similar workaround in Ash yet.

You can make multi tenancy global? true and add your own conditional check on tenant being set.

multitenancy do
  global? true
end

validations do
  validate RequireTenant # this validation allows specific actions to bypass tenant
end

preparations do
  prepare RequireTenant # this preparation does the same for read actions
end
1 Like

multitenancy option is added to read action in Ash 3.0. cool!