web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Setting Text Inputs Di...
Power Apps
Answered

Setting Text Inputs Directly

(0) ShareShare
ReportReport
Posted on by 7

Hi everyone,

 

I'm trying to build an app that utilises a series of text inputs and I've hit a bit of an issue. The text inputs should be fillable by 2 different methods; manual entry and barcode scanning. The barcode scanning was simple enough - I set the default value to a local variable and then used UpdateContext with the barcode scanner value but the issue is that if someone attempts a manual entry then the field no longer uses the local variable.

So my question is this: Is there a way to set the text value of a text input using a button (or barcode scanner in this case) WITHOUT using a local variable as the default value?

 

I tried this but nothing happened:

 

 

 

 

TextInput1.Text = BarcodeScanner1.Value

 

 

 

 

I'm assuming TextInput1.Text is a read-only field?

 

Thanks

Categories:
I have the same question (0)
  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at

    @RAMoore 

    It's not possible to assign the content of a text input control using the syntax you describe. The correct way is to use a variable, as you're currently doing.

    If you've set the default of TextInput1 to the variable and if the user were also able to manually type a value into TextInput1, why does this cause you a problem? Presumably, you can just reference the value in TextInput1 to retrieve either the barcode scanned or manually entered value.

  • RAMoore Profile Picture
    7 on at

    Hey @timl thanks for your reply. Apologies, I've also made a mistake in my original post. The issue is actually with using globals, not locals so I'll update the thread title accordingly.

    So to give a bit of context, this field essentially is to collect the serial number of a device but the app should be usable both on PC and phone. The assumption there would be that the user isn't using a barcode scanner on their PC, so they would need to do manual entry.

    RAMoore_0-1657666054511.png

    So for TextInput I've set the default value as a global called serial and the OnScan function for the 'Scan Barcode' button is:

    Set(serial, BarcodeScanner1.Value)

    I found that if a user manually enters a value into the TextInput, the 'Scan Barcode' button no longer works. I presume this is because the value of the field isn't 'serial' anymore.

    Essentially the desired behaviour here is that a user should be able to manually enter a value into the field and if for what ever reason they want to scan the barcode after, it should still be able to set the text value of the TextInput.

    I hope that makes sense and I really hope that's possible.

  • Verified answer
    timl Profile Picture
    36,411 Super User 2025 Season 2 on at

    Hi @RAMoore 

    Thanks for the detailed explaination. The answer to this is to reset the text input control after you set the variable. That will then override any text that the user might have entered into the control.

    Set(serial, BarcodeScanner1.Value);
    Reset(TextInput1)

     

  • RAMoore Profile Picture
    7 on at

    Perfect! Works like a charm. Thanks so much for your help.

  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at

    You're welcome @RAMoore - glad to help!

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard