cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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
Highlighted
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.
Highlighted
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

Highlighted

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

Highlighted

@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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,095)