cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StephanCN
New Member

Cant Assign Variables to custom input property

So, let me explain it better. First of all im working in canvas app, and here is the situation:

 

I have a custom input property in a component, its type is text. Lets call it IN

I also have a variable in my app OnStart its like this:   Set(TextInput,"Hi");

 

Now, when I go to my component and to IN, I put on its formula bar -> TextInput

 

For some reason it doesnt recognize it, it gives the following error:

"Name isnt valid. The identifier isnt recognized"

 

example.jpeg

 

I have tried with different variables and initializing the variable in different places, like OnVisible, but it doesnt work either.

 

Any suggestion? If you need any more info, just tell me in the reply.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@StephanCN 

You cannot use variable, controls, datasources, etc. that are defined in your app (i.e. in your OnStart in this case) within the component itself.  The component is autonomous and can only use the controls and items defined within it.

When you create an Input property on a component you defined within it the "default" value that will be assigned to it.  Just as the Input property for a Button has its Text property set to "Button".  This is just the default (and it also defines the property signature and schema if it is a complex type).

To use your variable or other control values for you component, you would put these in the IN property (in your case) once you have added the custom component to your app and to that added component - not within the component.

 

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!

View solution in original post

7 REPLIES 7
CNT
Super User
Super User

@StephanCN Did you run the OnStart() after setting this variable?

Yes I did, And I also tried with a button so that I could manually change the value of the variable.

I also tried with old variables that I use for other stuff in the app.

@StephanCN Instead of a variable if you give a literal text "Hello" in the IN parameter does it work?

It does, I can normaly type anything and it works

RandyHayes
Super User
Super User

@StephanCN 

You cannot use variable, controls, datasources, etc. that are defined in your app (i.e. in your OnStart in this case) within the component itself.  The component is autonomous and can only use the controls and items defined within it.

When you create an Input property on a component you defined within it the "default" value that will be assigned to it.  Just as the Input property for a Button has its Text property set to "Button".  This is just the default (and it also defines the property signature and schema if it is a complex type).

To use your variable or other control values for you component, you would put these in the IN property (in your case) once you have added the custom component to your app and to that added component - not within the component.

 

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!

Thank you very much, I didnt understand that I have to put it in the deployed component, and not in the component itself. 

This should be in the documentation, I have spent so much time searching and found nothing.

RandyHayes
Super User
Super User

@StephanCN 

In a way, it is kind of documented, but not in specific terms.  You have to read between the lines to get the point of it.

In general, when you are building a component, I find it helpful to always think that I am creating a "button component".  Let's assume there was no Button control in PowerApps and you had to make one in a component, how would you go about it.  Look at the Button control (that does exist) and you can understand the Input and Output and Behavioral properties/actions.  So, as regarded before - the Text property - you would say "I want to be able to change the Text in my custom button" - so you would need an Input property that would do that.  And, you would need to provide a default value for it.  But it's just the default.  Since it is an input property, once the control is in your app, you can set it to whatever you want (just like the real button control).

 

Keep in mind in components, that you can only reference anything that is IN your component, not in your app...otherwise it would not be an independent component.

_____________________________________________________________________________________
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!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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