I'm trying to do something in a canvas app which I assumed was quite easy but obviously missing something here!
I'm trying to change a components input property on a button click. For example changing a label that's in a component when someone clicks a button. I've tried this with both text inputs and boolean inputs. I've tried to simplify the example here, and I'll describe a text input.
1. I created a component called MainTitle, and added an input called "TitleDescription".
2. I put a label into the component and into a label I put MainTitle.TitleDescription
3. On an app screen I inserted the component, it showed up as MainTitle_1
4. On app screen I selected the component, and in the property drop down I saw my TitleDescription, I set this to "Main Screen" and the label updated as expected.
5. I made a button, and in that button I tried to change the TitleDescription on click. I put in the code
MainTitle_1.TitleDescription = "New title";
This is where it goes wrong compared to what I expected. Clicking the button has no impact on what is shown on screen, and checking the input TitleDescription it hasn't changed.
Could someone point me in the right direction please? Thanks a lot!
Solved! Go to Solution.
Hi @James141
You should use a variable to make it work.
1) In your button OnSelect property, set a variable, let's name it "varTitle":
UpdateContext({varTitle: "New Title"})
2)In your component TitleDescription property, use the variable.
varTitle
Once you click on the button, it will have "New Title" as the TitleDescription
Hi @James141
You should use a variable to make it work.
1) In your button OnSelect property, set a variable, let's name it "varTitle":
UpdateContext({varTitle: "New Title"})
2)In your component TitleDescription property, use the variable.
varTitle
Once you click on the button, it will have "New Title" as the TitleDescription