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
RezaDorrani
Level 10

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

 

 

4 REPLIES 4
Super User
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.
RezaDorrani
Level 10

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

 

 

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!


RezaDorrani
Level 10

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 54 members 4,662 guests
Please welcome our newest community members: