I have a PCF control that invokes an external web service, and the web service details (URL and API Key) will be different in different environments. so these are exposed as input properties on the control. So far so good
However the form containing the control is part of a managed solution, so I can't edit the form and change the control values in each environment; I need to have those configured as environment variables
I'm doing something similar in flows and it works fine there - when I define the flow I can just refer to the environment variables, but when I place a PCF control on a form, I can only bind to a table column or set a static value; I can't reference an environment variable.
Thanks David, I ended up doing something similar. It would be nice if you could select environment variables when placing the control on the form the same way you can when setting up a flow but it looks like that feature isn't there at the moment.
Note that although there are 2 tables, you can retrieve both with a single query using `$expand`
webApi.retrieveMultipleRecords(
"environmentvariabledefinition",
"$select=schemaname,environmentvariabledefinitionid&$expand=environmentvariabledefinition_environmentvariblevalue($filter=statecode eq 0;$select=value)"
)
You could always make direct dataverse webapi calls inside de PCF control to get the environment variable value, but its not very user friendly as the values can be found in 2 different tables (environmentvariabledefinition or environmentvariablevalue)
I would recommend implementing a Custom API that retrieves the environment variable.
I have an implementation in my Generic Custom API project, ref : GetEnvironmentVariable · drivardxrm/Dataverse-CustomApis Wiki (github.com)
Once your Custom Api is defined, you can call it using context.webApi.execute
ref : How to call custom actions using PCF - Power Platform Community (microsoft.com)
You can use the Dataverse RestBuilder to get you going with the boilerplate code
Ex.
I really wish that there would be an easier way,
If anyone as a better approach, please share.
Hope this helps!
WarrenBelz
87
Most Valuable Professional
mmbr1606
71
Super User 2025 Season 1
Michael E. Gernaey
65
Super User 2025 Season 1