How to programatically retrieve the URL of an entity

Hello,

I’m setting up an email notification system within an application. When an user’s finalized certain actions, an email will be sent to the concerning people. I want to add in this mail the URL of the entity where the related action has been done. Given I have several projects (workspaces) and each workspace can contains a certain number of entities, is there a way to programatically retrieve the URL of any entity?
Thanks you in advance.

Best regards,
Huy

Hi @vuquochuy ,

This is indeed possible. You will notice that the URL for every entity has the following structure:

https://{organization_subdomain}.viktor.ai/workspaces/{workspace_id}/app/editor/{entity_id}

With the organization subdomain remaining unchanged within your VIKTOR environment, you can simply hardcode this (except if you have multi-region). The workspace_id and entity_id can be retrieved from the kwargs from one of your Controller endpoints, e.g.:

my_method(self, params, workspace_id, entity_id, **kwargs)

If you have a multi-region setup, you can retrieve your region from the environment variable “VIKTOR_ENV”.