Update Environment Variables
Table of Contents
We all know the scenario, a managed solution has been imported but one of the variables has been set incorrectly. How do I go and update this to the correct value? Within Dataverse there are 2 tables called ‘Environment Variable Value’ and ‘Environment Variable Definition’ these store the value of each variable and the definition of the variable respectively. The following guides will explain how to build a canvas app and/or a Flow to update the values only.
The two guides documented below are:
- Update variables in Dataverse using a canvas app
- Update variables in Dataverse using Power Automate
You can of course go into each table and update them manually.
Using a Canvas App #
The canvas app will only find and update variables in the environment the app is in. The three main controls used in the app are:
- Gallery
- Edit Form
- Button
- Create a new app using the tablet format
- Add the two Dataverse tables called ‘Environment Variable Value’ and ‘Environment Variable Definition’ as datasources
- Add a gallery to the screen and set the datasource as ‘Environment Variable Definition’
- Set the following properties as below
X: 0
Width: 700
- Change the layout of the gallery to ‘Title and subtitle’
- In the gallery select the title control and update the text to
ThisItem.'Display Name'
- Add an Edit Form and use ‘Environment Variable Value’ as the datasource
- Set the following properties as below
X: 700
Width: Parent.Width - Self.X
Item: LookUp('Environment Variable Values', 'Environment Variable Definition'.'Environment Variable Definition' = Gallery1.Selected.'Environment Variable Definition')
- In the Form add the following controls in order
- Created On
- Value (value is the part to be updated)
- Finally add a button control
- Update the OnSelect function to
SubmitForm(Form1)
Your app should be similar to the image below
You can now test the app in preview mode. Selecting an item in the galley making sure the form gets populated. Update the value to the required value and finally press the button.
Using a Power Automate Flow #
This guide explains how to create a manually triggered instant cloud flow to update environment variables. There will be 2 inputs to add both of which will be text.
- Name of the variable to update
- Value to update the variable to
To create the Flow we will use the actions
- Manually trigger a flow
- List rows (x2)
- Compose
- Update Rows
- Create a new instant cloud flow with the ‘Manually trigger a flow’ trigger and give it a name
- Within the trigger add two text outputs
- Variable Name
- New Value
- Add the Dataverse action ‘List rows’
- Rename to ‘List row from definition table’
- Table name = Environment Variable Definitions
- Filter rows = displayname eq ‘Variable Name’ from trigger
- Add a ‘Compose’ action
- Rename to ‘Compose schema name’
- Inputs = first(body(‘List_row_from_definition_table’)?[‘value’])?[‘schemaname’]
first(body('List_row_from_definition_table')?['value'])?['schemaname']
- Add the Dataverse action ‘List rows’
- Rename to ‘List row from value table’
- Table name = Environment Variable Values
- Filter rows = schemaname eq ‘Output’ from ‘Compose schema name’
- Add the Dataverse action ‘Update a row’
- Rename to ‘Update value in value table’
- Table name = Environment Variable Values
- Row ID = first(body(‘List_row_from_value_table’)?[‘value’])?[’environmentvariablevalueid’]
- Schema name = ‘Output’ from ‘Compose schema name’
- Value = ‘New Value’ from trigger
first(body('List_row_from_value_table')?['value'])?['environmentvariablevalueid']
Your flow should be similar to the image below
Once complete you can start testing your flow. Click ‘Test’ and select ‘Manually’ from the menu and press ‘Test’. Enter your variable name as well as the value to update it to and press ‘Run flow’.