I am building a PCF control targeting to portal, canvas app and model driven app.
One challenge I am facing with API call.
For portal app, I need to call custom api which will not work in canvas app I think.
So my question is how my PCF control will identity in which environment the control is running like in portal app or canvas app or model driven app so that I can call different API according to the platform identification?
Hi @Anonymous ,
To detect where the PCF is running, I have an idea posted, maybe you want to vote it: https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Runtime-possibility-to-detect-if-the-PCF-is-running-in/idi-p/500232
Until not long ago, was not not possible to detect this, since the framework would show a message, if you call a context.webAPI function. But lately the error message is not shown anymore, so you can try with a "catch", and if it doesn't work, can go with the next way. That's actually what the SDK now says: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/code-components-best-practices?WT.mc_id=BA-MVP-5004107#check-api-availability
Hope this helps!
Kind regards,
Diana
WarrenBelz
109
Most Valuable Professional
Michael E. Gernaey
82
Super User 2025 Season 1
mmbr1606
71
Super User 2025 Season 1