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 / Environment Variable -...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by

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

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 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard