cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LeeHarris
Solution Sage
Solution Sage

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!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

1 ACCEPTED SOLUTION

Accepted Solutions
RezaDorrani
Dual Super User II
Dual Super User II

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
Pstork1
Dual Super User III
Dual Super User III

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
Dual Super User II
Dual Super User II

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

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!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

@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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,826)