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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Environment Variable -...
Power Apps
Unanswered

Environment Variable - Using a Web Resource (Javascript) to access the Environment Variable value

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, 

 

I have created an Environment Variable in my Power App Solution and I want to access the value of the variable using the Web API in a Web Resource with JavaScript.

 

Could this done using XRM in Javascript ?

 

Thanks

- Rory

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello Rory,

    Generally speaking "Environment Variable" is 2 entities in CDS that are available through api.

    You should query entities environmentvariabledefinition (to apply the filter by variable name) and environmentvariablevalue to get the value. Generally speaking following FetchXml should bring you what you need:

    <fetch>
     <entity name="environmentvariabledefinition" >
     <filter>
     <condition attribute="schemaname" operator="eq" value="test" />
     </filter>
     <link-entity name="environmentvariablevalue" from="environmentvariabledefinitionid" to="environmentvariabledefinitionid" >
     <attribute name="value" />
     </link-entity>
     </entity>
    </fetch>
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    An improvement on the above is to make it an outer join and to also return the DefaultValue from the environment definition - then you have the ability to cater for if the environment variable is not set in an environment.

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    As the previous users mentioned, you can. A clean way if you want to avoid fetchXML is with the out-of-the-box client web api script, retrieveRecord.

    Xrm.WebApi.retrieveRecord("environmentvariablevalue", <GUID>, "?$select=value").then(successCallback, errorCallback);

    Note: the GUID of the environment variable value will be the same in the different environments if you imported the variable with a solution.

     

    More info: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord

     

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard