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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I reference an...
Power Apps
Unanswered

How can I reference an environment variable when binding to a PCF control?

(0) ShareShare
ReportReport
Posted on by 50

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.

 

I have the same question (0)
  • Verified answer
    David Rivard Profile Picture
    20 Most Valuable Professional on at

    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.

    DavidRivard_0-1711063601375.png

     

    I really wish that there would be an easier way,

    If anyone as a better approach, please share.

     

    Hope this helps!

  • Tim Robinson Profile Picture
    50 on at

    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)"
    )

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard