How to get the current Environment URL in Canvas App or Custom Page?

 To get the Current Environment in canvas app,we can perform the following step:


Step 1: Include Canvas App data source in app and connector PowerAppForMakers as below screenshot.



Step 2: Set the below variable on load or particular event of the screen. 

the variable varCurrentEvironmentURL will store the environment url.

Set(currentAppURI, First('Canvas Apps').AppOpenUri);

Set(currentEvmtId, Right((Match(currentAppURI,"/e/.*(?=/a)").FullMatch),36));

ClearCollect(
    collAllEnvironments,
    AddColumns(
        Sort(
            PowerAppsforMakers.GetEnvironments().value,
            DataSourceInfo.DisplayName
        ),
        "DisplayName",
        properties.linkedEnvironmentMetadata.friendlyName,
        "Url",
        properties.linkedEnvironmentMetadata.instanceUrl
    )
);


Set(
    currentEnvironmentURL,
    First(
        Filter(
            collAllEnvironments,
            currentEvmtId in id
        )
    ).Url
);


Featured Posts

Download CRM 365 V9.X Tools using PowerShell

This configuration explains about how to download D365 utility tools step by steps. Step1 : Create a folder in your particular drive where y...

Popular Posts

Contact Me

Name

Email *

Message *