cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vladimir84
Helper V
Helper V

Canvas components app scope bug - Component libraries

Ref: Canvas components can now access app scope directly | Microsoft Power Apps

for the purpose of: Collaborative Development for PowerApps Canvas Apps | Microsoft Power Apps

 

Access app scope mentioned is unavailable, the component library created today. 

 

The objective is that devs can develop the components within the libraries and then the main dev assembles them.

To do that, the devs need to see how will components work with the data sources (not to mention to correctly call the data sources inside the component).

 

I can do that with the collections, by enabling the "retired" feature of components access to collections. Then, I collect the data on the main screen (through a button) and set the collection name on the input parameter of the component.

 

But I need also components to access the variables of the main app. I tried setting the properties like for collections, without success.

 

How do I do that?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @vladimir84 ,

 

The point is to create color input parameter.

I did a test for you.

Add a button control and set its onselect property to:

Set(varTestVariable,{Red:Red,Green:Green})

vxiaochenmsft_0-1636015573394.png

 

Add a component and create 2 parameters.

vxiaochenmsft_1-1636015668283.png

vxiaochenmsft_2-1636015681158.png

vxiaochenmsft_3-1636015691917.png

vxiaochenmsft_4-1636015705112.png

vxiaochenmsft_5-1636015718122.png

 

Best Regards,

Wearsky

View solution in original post

5 REPLIES 5
PTBBSolutions
Solution Supplier
Solution Supplier

Hi @vladimir84 ,

 

Did you try to write the Collect function although it doesnt appear? It works for me. The minute I write 'Collect(', it start behaving normally.

@vladimir84 , The scope option is only available for components in app and not available for components in component library. Though you can create a collection in app scoped in library, you should be able to use that collection to define custom input property type of a component. If you want to define custom output property type then you need to create the collection inside a component.

 

For example,

Define a collection in app scope in library.

Button1.OnSelect = Collect(MyCollection, ...)

 

Inside a component, add an input property and define rule on it

Component1.CustomInputProperty = MyCollection

 

For defining output property type, create a collection inside a component

Component1.HiddenButton.OnSelect = Collect(MyInternalCollection, ...)

Component1.CustomOutputProperty = MyInternalCollection

 

I hope this helps.

@ShantanuP  and @PTBBSolutions  thank you for your input.

However, you completely missed my question 😊 Perhaps I should have put it in the headers or I was not clear.

 

I need to access variables inside the component, which are created via Set() on the main screen. How do I do that?

 

E.g. this is the code: 

Set(varTestVariable,

{White: RGBA(255,255,255,1),
Black: RGBA(0,0,0,1)}
)
(all the corporate colors)
 
 
so instead of repeating the colours, I simply use varTestVariable.White

 

Now the problem is that I cannot load the variable in the main app and access it inside the component. I tried setting the type as Input, Output, Collection, Record, Text...nothing works.

 

v-xiaochen-msft
Community Support
Community Support

Hi @vladimir84 ,

 

The point is to create color input parameter.

I did a test for you.

Add a button control and set its onselect property to:

Set(varTestVariable,{Red:Red,Green:Green})

vxiaochenmsft_0-1636015573394.png

 

Add a component and create 2 parameters.

vxiaochenmsft_1-1636015668283.png

vxiaochenmsft_2-1636015681158.png

vxiaochenmsft_3-1636015691917.png

vxiaochenmsft_4-1636015705112.png

vxiaochenmsft_5-1636015718122.png

 

Best Regards,

Wearsky

Thank you @v-xiaochen-msft that's exactly what I needed.

It's a pity I have to manually declare all of them, but at least it works 

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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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,404)