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 / PowerApps Set Textbox ...
Power Apps
Unanswered

PowerApps Set Textbox to auto populate and also change text on list OnSelect value

(0) ShareShare
ReportReport
Posted on by 73

Hello,

 

I am working on a FORM where a textbox (SubstationInput) is set to pull a SP column value based on a Lookup function and the below code works perfectly. Basically the code will auto-populate the location on the Textbox if Lat/Long values match the SP columns if not it will display as " You are not at a substation". 

 

With(

{
wRecord: LookUp(
'SharePoint List',
field_1 = Location.Latitude && field_2 = Location.Longitude
)
},

Coalesce(wRecord.Title, "You are not at a Substation")
)

 

I also have a button on the same form to choose a location if the user is not at a Substation. The button opens a Gallery with list of locations to choose and I have the Gallery Onselect property as Navigate(NewFormScreen).

 

Now what I want is that initially when the form opens the textbox should auto-populate the location and if when a user select's a location in the list then the screen should navigate back to form and clear the existing text and the selected location should be populated on the SubstationInput Textbox. I am able to achieve this separately (using below code on the Textbox default property) without the lookup function and it works perfectly.  

 

BrowseGallery2.Selected.SubstationName

 

But I am stuck achieving both functionality together (Location auto populate using lookup function & pass text from gallery onselect to same textbox by clearing exiting text). So far I have the below using If condition but throwing error.

 

If(!IsBlank(SubstationInput.Text),

With(

{
wRecord: LookUp(
'SharePoint List',
field_1 = Location.Latitude && field_2 = Location.Longitude
)
},

Coalesce(wRecord.Title, "You are not at a Substation")
)

), BrowseGallery2.Selected.SubstationName

 

Please help.

Categories:
I have the same question (0)
  • Verified answer
    SpongYe Profile Picture
    5,603 Super User 2025 Season 2 on at

    Hi @PowerUser39 

     

    You can use a variable to store the selected location from the gallery, and then use that variable in the default property of the textbox.

     

    For example, in the OnSelect property of the gallery, you can use

    Set(
     SelectedLocation, 
     ThisItem.SubstationName
    )

    to assign the selected location to a variable named SelectedLocation. Then, in the default property of the textbox, you can use 

    If(
     IsBlank(SelectedLocation), 
     Coalesce(
     wRecord.Title, 
     "You are not at a Substation"
     ), 
     SelectedLocation
    )

    to display either the auto-populated location or the selected location.

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @PowerUser39 ,

    Looks like a bracket in the wrong place for a start

    If(
     !IsBlank(SubstationInput.Text),
     With(
     {
     wRecord: 
     LookUp(
     'SharePoint List',
     field_1 = Location.Latitude && field_2 = Location.Longitude
     )
     },
     Coalesce(
     wRecord.Title, 
     "You are not at a Substation"
     )
     ), 
     BrowseGallery2.Selected.SubstationName
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • PowerUser39 Profile Picture
    73 on at

    @WarrenBelz Thanks for your response. I corrected the bracket but still getting the below error

    PowerUser39_0-1697406356940.png

     

  • PowerUser39 Profile Picture
    73 on at

    @SpongYe Thanks for your response. Tried your solution but getting below error and also on the gallery OnSelect getting incompatible type and invalid name error. 

  • SpongYe Profile Picture
    5,603 Super User 2025 Season 2 on at

    Hi @PowerUser39 

     

    Change that to

    Set(
     SelectedLocation, 
     BrowseGallery2.Selected.SubstationName // or SubstationInput.Text
    )

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • PowerUser39 Profile Picture
    73 on at

    @SpongYe I trimmed a bit to your code and got it working.

     

    OnSelect property of the gallery

    Set(SelectedLocation,BrowseGallery2.Selected.SubstationName);Navigate(NewFormScreen,ScreenTransition.None)

     

    Text Default Property
    If(
    IsBlank(SelectedLocation),
    With(
    {
    wRecord:
    LookUp(
    'SharePoint List',
    field_1 = Location.Latitude && field_2 = Location.Longitude
    )
    },
    Coalesce(
    wRecord.Title,
    "You are not at a Substation"
    )
    ),
    SelectedLocation
    )

     

    Thanks for helping 🙂

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard