Do you often struggle to determine in which organization you are currently working within a flow? Do you think environment variables cause to much overhead to only determine the base url? Well, I do. Let’s check on how I resolved it.
A client wanted to have a clickable link in an email referring to the current case working on. To achieve this, I needed to know in which environment the flow was currently running. Next, I can concatenate the base URL of the org together with the parameters, like entitytpe and id.
To determine this, I took advantage of the data returned from a “Get record” action of the CDS connector. When querying, the odata.id field contains the link to the record. This also contains your organization! Let’s add the compose action of “Data Operations” to your flow and get to work.
The expression to determine looks like this:
Replace the action_name with the appropriate action name in your flow. To explain what this function does:
- We first get the outputs of the action where the get record is done.
- We check the body if it contains the @odata.id field
- If it does, we do a split operation which will seperate all the values before the ‘/api’ value and after.
- Since our organization is before, we do apply a first() (split returns an array)
To wrap up, in the description field of the email you can add <a href=”outputs(‘Compose’)/main.aspx?etn=entitytype&id=triggerOutputs([‘body/entityid‘])”>link</a> to display the link to your entity. Do note to replace entityid and entitytype with the corresponding values. In our case outputs(‘Compose’) will return the baseurl.
Do you use this to find out the base url of your environment within a flow, or do you use another way? Let me know!