Hi! I'm new to Power Apps, and currently making a canvas app using Dataverse for Teams. I want to use environment variables to store information that needs to be changed when importing the app to another enviromnet, but I'm having trouble using LookUp() to access the current value of the environment.
I've added the environment variable ('testVariable') to the solution in the Power Apps for Teams app, and added the connections to the two tables 'Environment Variable Definitions' and 'Environment Variable Values' in my app.
My problem is that the values for 'Schema Name' in the two tables are different, so I can't get LookUp() to work. The value in the 'Environment Variable Valu es' table was added automatically, but it just seems to have and ID, and not the actual name of the variable like in the 'Environment Variable Definitions' table.
I'm able to get the Default Value of the environment variable by using a LookUp() to the Definitions table, but I want to use the Current Value for this environment.
Here's the code that works (default value):
LookUp(
'Environment Variable Definitions',
'Schema Name' = "cr896_testVariable"
).'Default Value'
And here is the code that doesn't work, because there is no value in the Values table that matches the variable name:
LookUp(
'Environment Variable Values',
'Environment Variable Definitions'.'Schema Name' = "cr896_testVariable").Value
Can someone please help me understand how I can get the current value from the tables? Thank you.
Hi @StineN, to handle both cases in one expression 1) where there's a current value and 2) when there's no current value but just a default value:
Coalesce(
LookUp(
'Environment Variable Values',
'Environment Variable Definition'.'Schema Name' = "name",
Value
),
LookUp(
'Environment Variable Definitions',
'Schema Name' = "name",
'Default Value'
)
);
Tip! I put this as a Named Formula to centralize the logic so it can be reference in many places.
Hope this helps!
Thank you for your reply. I did indeed get the current value using that formula, but it doesn't seem to be consistent in terms of which variable it looks up. It doesn't seem to work when I'm having several environment variables.
When I first tried the formula, it returned the current value of another variable in the same environment. When I deleted all of the values from my other environment variables, it indeed returned the current value of "testVariable". But when I added another variable called "testVariableName" and gave it the current value "Stine", it still returned the value of "testVariable" even if I changed the schema name in the formula to the new variable. Not sure how that's possible.
Any thoughts? Thanks again!
Hi @StineN ,
We Create the Environment Variable blow.
The formula of Current Value:
LookUp(
'Environment Variable Values',
" cr896_testVariable" in 'Environment Variable Definitions'.'Schema Name' ,
Value)
Hope this will help you,
Best Regards,
Tina
WarrenBelz
198
Most Valuable Professional
MS.Ragavendar
108
stampcoin
80