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"
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.
Solved! Go to Solution.
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.
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
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.
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.
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.
User | Count |
---|---|
252 | |
126 | |
105 | |
50 | |
49 |