Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

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.

 

  • Tim Robinson Profile Picture
    50 on at
    Re: How can I reference an environment variable when binding to a PCF control?

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

     

  • Verified answer
    David Rivard Profile Picture
    20 Most Valuable Professional on at
    Re: How can I reference an environment variable when binding to a PCF control?

    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!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard