web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using environment vari...
Power Apps
Unanswered

Using environment variables when moving solutions between environments

(0) ShareShare
ReportReport
Posted on by 96

Hi,

I have a solution containing a cloud workflow that copies folders and files from a document library on a SharePoint site. Since the solution will be moved between environments both within our own tenant and eventually to a customer’s tenant, the Site Address must be dynamic. This is how it looks in my Dev env. (and it works as expected):

Rydman_1-1647598534604.png

 

If I export and then import the unmanaged solution into my Test env. and don’t change anything, it still works, in the sense that I can manipulate SharePoint folders, but obviously on my Dev SharePoint site as set in the environment variable like this (it’s got a crappy name, I know…):

 

Rydman_2-1647598566970.png

Then I change the variable to my Test site:

 

Rydman_3-1647598591983.png

When I stop/start my flow, I get the following error message:

Turn on failed. Flow client error returned with status code "BadRequest" and details "{"error":{"code":"InvalidOpenApiFlow","message":"Flow save failed with code 'DynamicOperationRequestClientFailure' and message 'The dynamic operation request to API 'sharepointonline' operation 'GetTable' failed with status code 'NotFound'. This may indicate invalid input parameters. Error response: {\r\n \"status\": 404,\r\n \"message\": \"List not found\\r\\nclientRequestId: 9b57a71c-ba1d-4595-8a82-8842cf75a6f0\\r\\nserviceRequestId: 9b57a71c-ba1d-4595-8a82-8842cf75a6f0\"\r\n}'."}}".

 

And if I go and look in my flow, the Create project folder configuration looks like this:

Rydman_4-1647598675098.png

 

The List or Library now has a GUID and not a symbolic name which leads me to suspect that it does not point to the identically named document library on the Test site but maybe to the GUID of the library on my Dev site. But that’s just a guess.

 

And this doesn’t even begin to address the issue of trying to do this with a managed solution, in which case, to the best of my understanding, I can’t even change the environment variable, nor the issue of how to automate this in my CI/CD pipeline (some googling on the latter topic seems to indicate that this is a less than mature area).

 

Any help on how to fix the immediate problem would be much appreciated. For a while we can live with working with an unmanaged solution. But for environment variables to be of any use they must at a minimum be editable when manually importing a managed solution, so help on this topic is also appreciated. Input on the third CI/CD topic would be a bonus.

 

Thanks!

 

I have the same question (0)
  • Hamish Sheild Profile Picture
    3,005 Most Valuable Professional on at

    Hi @Rydman 

     

    This List or Library parameter is an ID as you have discovered rather than a path.  In your environment variables you can set up a environment variable that points to a SharePoint List e.g.

    HSheild_0-1647628241765.png

     

    To edit an environment variable value that is in a managed solution, you simply go to the Default solution and edit there.

     

    To set Environment Variable values during CID/CD using Azure DevOps you can use Microsoft Power Platform Build Tools and a Deployment Settings file. Pre-populate connection references and environment variables for automated deployments using Power Platform Build Tools - Power Platform | Microsoft Docs

  • Rydman Profile Picture
    96 on at

    Hi @HSeild,

    Thanks for your succinct and precise answer! I’ve managed to get past the two first issues. However, I run into a snag that still stops me from trying out the third step. Here’s where I’ at:

     

    I added a new Environment variable for the SharePoint Library and use it in the flow (Both the Site and the Library env.variable name starts with the same characters but they are different):

    Rydman_0-1647957238511.png

    This works as expected in my dev environment. Folders are created and files are copied into my Dev SharePoint site.

     

    I then export/import a managed Solution to my Test env and change the environment variable values in the Default Solution as per instructions:

     

    Rydman_1-1647957297356.png

     

    The fact that my Doc Library appears in the dropdown list when the Site is designated by my other env. variable is promising…

     

    When I run my flow, the folders get created in my Test SharePoint environment which, as far as I can understand, indicates that my two env. variables work correctly. However, when I get to the Copy file bit, I get an error (i.e. the same config works in Dev but not in Test). The error is indicated as "Action 'Apply_to_each_file' failed":

     

    Rydman_4-1647961305031.png

     

    I’d expect the Library string (which has its symbolic name in the File To Copy filed but it’s GUID in the Destination Folder) to be identical in both fields, but it’s not.

     

    Here’s the config for the Copy File:

    Rydman_3-1647957472405.png

    I’ve had problems in the past with the exact composition of the path strings, but since it works in Dev that does not seem to be the issue.

     

    Any help is greatly appreciated (again!).

     

     

  • Jakebrowno Profile Picture
    29 on at

    Did you ever find a solution to this? I am having a similar issue

  • Jakebrowno Profile Picture
    29 on at

    Found the answer thanks to @sipsUp  and this thread: Data Source Environment Variables - Connect to Sha... - Power Platform Community (microsoft.com).

     

    Essentially you have to find the Drive ID for the Library in question.

    You do this by using a test flow a "hard coded" (i.e. not environment variables) Excel link to the library and checking the inputs in the run flow.

    Then create a text environment variable with that drive ID. 

  • ahmedsassi Profile Picture
    7 on at

    hello,

    you need GUID of the document library, for this: 

    siteURL/_api/v2.1/drives

    you will get all drives in your sharepoint site and you copy paste the id 

    2023-06-12 11_02_40-Window.png

    save the id value in environment variable type text and do the same thing for test and prod env then update value 

    insert the variable environment in your flow for the document library and it's ok 

    if it's ok for your please mark my answer as response to help other people

    have nice day

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 490

#2
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 381

Last 30 days Overall leaderboard