cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SteveFeldman
Helper I
Helper I

Can a component in a library refer to another component

We have a Component library which includes a firmColors function returns a color (enum) based on a text parameter (e.g. "Royal Blue").  This is performing well.  We are now building a component which display a gallery of data.  There is a rectangle behind all of the other controls whose Fill color is based on a field value.

 

My question is:  can this new component make use of our firmColor component so we do not need to duplicate the color table?

 

I suspect our long term solution will be to place this table in the DataVerse, I am not quite at that level of craftpersonship.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@SteveFeldman 

Gotcha on the custom color names.

 

Yes, a component is designed to be a portable object that can be used in any app.  So creating a dependency on a datasource, for example, breaks that portability.  It says that, any app that hosts that component must have a connection to the datasource.  That is a dependency.

 

You can, create a component to have that dependency.  PowerApps does allow it to happen, but this is a retired feature that allows it.  That feature has been replaced with the Access app scope property on the component.

But a lot of that changes quite often as these features are somewhat experimental at this point.  In fact, I'm not even currently seeing that property any more.

 

But still, dependencies in the components is generally not a good way to go.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@SteveFeldman 

You cannot reference another component in a component.  They are currently autonomous.

 

Also I would avoid data interactions with your components directly to a datasource.  This creates a reliance on the host app which breaks the concept of a component.

 

Also, in terms of your color component - are you aware that you can already convert a color in text into a color? - ex: ColorValue("RoyalBlue") will return the RoyalBlue color.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
SteveFeldman
Helper I
Helper I

Wow, thank you for the prompt reply. 

 

WRT the color value, the colors are actually custom, not the OOTB choices.  For examples the text label may be something like "Retail Primary", "Retail Shadow", "Government Primary", International Primary", etc.   I was doubtful components could refer to each other, the dependencies and relationships could easily.

 

I was thinking using a table in the DataVerse separate the business logic layer from the data layer and could be shared by components, solutions and apps within an environment.  But if I interpret you reply correctly, the data connection is through the host app and not the component.

 

RandyHayes
Super User
Super User

@SteveFeldman 

Gotcha on the custom color names.

 

Yes, a component is designed to be a portable object that can be used in any app.  So creating a dependency on a datasource, for example, breaks that portability.  It says that, any app that hosts that component must have a connection to the datasource.  That is a dependency.

 

You can, create a component to have that dependency.  PowerApps does allow it to happen, but this is a retired feature that allows it.  That feature has been replaced with the Access app scope property on the component.

But a lot of that changes quite often as these features are somewhat experimental at this point.  In fact, I'm not even currently seeing that property any more.

 

But still, dependencies in the components is generally not a good way to go.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

You cannot reference another component in a component.
in your color component you have already convert a color in text
into a color? - ex: ColorValue("RoyalBlue") will return the RoyalBlue color.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,771)