cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

CDS Is it possible to determine the Current Environment at runtime?

Hi,

I have a flow set up that connects to CDS using the current environment connector which makes deployment far simpler. This flow ends by sending out a series of email notifications. When the flow is running in the Live environment it needs to send the emails to users (pulled from the CDS records). However, when the flow is running in the development sandbox environment I would like it to send all notifications to a fixed email address.

Is there any way of knowing which environment the flow is in at runtime? If I can get access to this value I can add a switch statement and I won't have to make changes to the flow in each environment.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: CDS Is it possible to determine the Current Environment at runtime?

Hi @LeeHarris ,

 

You could store the email addresses in an entity and query the entity for current environment and send notifications

This would help in setting different notif email addresses per envrionment

 

Also,

when you query CDS using Flow and set envrionment to current example :List records

the response Body does have the environment info

 

example

{
"@odata.context": "https://unitedstates-002.azure-apim.net/apim/commondataservice/4c0d81ac535a4ee492a4233807abe164/$met...",
"value": [
{
"@odata.id": "https://org0271c79a.crm.dynamics.com/api/data/v9.0/accounts(07dbfaaa-1895-e911-a956-000d3a36eaef)",

 

You could use Flwo expressions to pull this info out and then accordingly send emails

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

4 REPLIES 4
Dual Super User
Dual Super User

Re: CDS Is it possible to determine the Current Environment at runtime?

It might just be easiest to add a value to one of the existing entities in both environments or a new entity and save the name of the Environment there.  Then you could retrieve it.  I'm not aware of any system variables or values that would let you determine the current environment.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Dual Super User
Dual Super User

Re: CDS Is it possible to determine the Current Environment at runtime?

Hi @LeeHarris ,

 

You could store the email addresses in an entity and query the entity for current environment and send notifications

This would help in setting different notif email addresses per envrionment

 

Also,

when you query CDS using Flow and set envrionment to current example :List records

the response Body does have the environment info

 

example

{
"@odata.context": "https://unitedstates-002.azure-apim.net/apim/commondataservice/4c0d81ac535a4ee492a4233807abe164/$met...",
"value": [
{
"@odata.id": "https://org0271c79a.crm.dynamics.com/api/data/v9.0/accounts(07dbfaaa-1895-e911-a956-000d3a36eaef)",

 

You could use Flwo expressions to pull this info out and then accordingly send emails

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

Highlighted
Super User
Super User

Re: CDS Is it possible to determine the Current Environment at runtime?

Hi @RezaDorrani 

Thanks for pointing out the Url in the response body of the List Entity request.

I was able to use the Parse JSON action to extract the @odata.id property and then added a condition to send a different email if the url contained the name of the dev or UAT environment. I should now be able to test without sending any live emails to any users in the system, and deploy to production without the need to edit the Flow process.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Dual Super User
Dual Super User

Re: CDS Is it possible to determine the Current Environment at runtime?

@LeeHarris 

 

Great !!!

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,477)