Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Get/Set Text in Component

(0) ShareShare
ReportReport
Posted on by 19
Hello,
I am creating a component that will allow a user to enter text data, and click a save button. I then need to grab that text and do stuff with it.
 
This component has 3 controls: a TEXTINPUT (commentsText), a button to save and a button to cancel.
 
I have also created 4 custom properties for the control: the OnSaveClick event, the OnCancelClick event, the DefaultText input, and the CommentText output. The DefaultText text is intended to initialize the Text property of the commentText control, and the CommentText property is intended to be what I read to get the users input when the OnSaveClick event is raised.
 
My problem is that I am not able to 1) set the commentText to the DefaultText, and 2) read back what the user entered.
 
I have a button that I use to show the component using the following code in the button's OnSelect property:
rmaCommentBox.DefaultText="Add your comments here...";
UpdateContext({varShowRmaComments:true});
 
I am using this code to read back the user's input:
Notify("Comments: " & rmaCommentBox.CommentText);
 
Inside the component I am setting the Value property of the commentText control to the following code:
CommentBox.DefaultText
 
Then in the SaveButton.OnSelect I am using the following code:
CommentBox.CommentText=CommentBox.DefaultText;
CommentBox.OnSaveClick()
 
I know I'm not doing something right, but I'm not sure what that is. Can anyone lend a bit of insight as to what my problem is?
 
Thanks for looking
Kevin
Categories:
  • KevinBod Profile Picture
    KevinBod 19 on at
    Get/Set Text in Component
    What exactly do you find concerning?
     
  • IAmIntractable Profile Picture
    IAmIntractable 204 on at
    Get/Set Text in Component
    This post is interesting to me to see if anyone posts about the fact that you are using an experimental feature (custom behavior). One that has been in the experimental state for 4 years and one that is essential to the Microsoft component strategy. This is concerning. 
     
    That said,
     
    DefaultText is an input property to the component and it needs to be set outside the component in actual use though you can set its default by placing "Add your comments here" to the property inside the component so it has a value to work with during development.
     
    This should read:
    CommentBox.CommentText=CommentBox.Text;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard