
In my private project (Key Box), I stored a JSON configuration in an Environment Variable. To retrieve its value, I use two queries. The first query to retrieve the GUID of the Environment Variable Definition and the second query to retrieve the Environment Variable Value. I don’t use the Retrieve EnvironmentVariableValue function because I also need to update the environment variable later.
Set(
envVarDefRec;
First(
Filter(
'Environment Variable Definitions';
'Schema Name' = "new_YourSchemaName"
)
)
);;
Set(name; value) to create the variable envVarDefRec and store the value.
First(table) to get the first record of the passed table.
Filter(table; condition) to filter the Environment Variable Definitions table by scheme name.
Set(
envVarValRec;
First(
envVarDefRec.'Environment Variable Values'
)
);;
Set(name; value) to create the variable envVarValRec and store the value.
First(table) to get the first record of the passed table.
Set(name; value) to create the variable envVarVal and store the value of envVarValRec.Value.
Set(envVarVal; envVarValRec.Value);;
If(condition; then) to do the next action only if the condition is fulfilled.
IsBlank(value) to check is envVarVal contains data.
Set(name; value) to fill the variable envVarVal and store the value of envVarValRec.Value.
If(
IsBlank(envVarVal);
Set(envVarVal;envVarDefRec.'Default Value')
);;
Original Post https://benjaminjohn.de/retrieve-environmentvariablevalue-in-power-fx






