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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,041)