cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shahriat
Helper II
Helper II

Same PCF control for portal, canvas app and model driven app

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?

1 ACCEPTED SOLUTION

Accepted Solutions
DianaBirkelbach
Super User
Super User

Hi @shahriat , 

 

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

 

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

 

Hope this helps!

 

Kind regards,

Diana

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

1 REPLY 1
DianaBirkelbach
Super User
Super User

Hi @shahriat , 

 

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

 

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

 

Hope this helps!

 

Kind regards,

Diana

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,052)