Skip to main content
Community site session details

Community site session details

Session Id : ccc2MxTfRlzcSG9sRPMzlW
Power Apps - Building Power Apps
Unanswered

Set Text field value from Combo box selection in a Form

Like (0) ShareShare
ReportReport
Posted on 10 Jan 2024 11:56:35 by 29

Hi all 

 

I have a "Request" SharePoint list that contains 2 fields , 1. Region combo box and 2. Segment text field.

I have a 2nd SP list that contains the Region Segment mapping e.g. 

 

RegionSegment
Region 1Segment 1
Region 2Segment 1
Region 3Segment 1
Region 4Segment 2
Region 5Segment 2
Region 6Segment 3

 

All I'm looking to do is set the Segment value in the Segment text field based on the Region combo box selection.

I've seen posts that say set the default value of the Segment text field to comboRegion.Selected.Segment.

This doesn't work fully because as soon as you save the form the Segment text field appears blank even though the data source as been updated correctly.

 

So how do you keep the value in the Segment text field in the form in View and edit Mode (after it has been saved) and then only update it if a user was to change the Region selection ? 

  • WarrenBelz Profile Picture
    149,102 Most Valuable Professional on 12 Jan 2024 at 07:31:20
    Re: Set Text field value from Combo box selection in a Form

    @markliam ,

    There is a solution as I described - I just thought you would have a attempt - I am happy to look at your code and correct if necessary.

  • markliam Profile Picture
    29 on 12 Jan 2024 at 07:29:27
    Re: Set Text field value from Combo box selection in a Form

    OK so we don't have a solution to this..

     

    I'll try a few things and if I get it to work will post here.

    I have a similar process in another App but never used a Form, use variables and Patch, but was hoping Forms might make life easier, doesn't seem to be the case..

     

     

  • WarrenBelz Profile Picture
    149,102 Most Valuable Professional on 11 Jan 2024 at 20:34:05
    Re: Set Text field value from Combo box selection in a Form

    @markliam

    You are correct that it may need some sort of variable triggered OnChange and make the Default conditional on it being false.

  • markliam Profile Picture
    29 on 11 Jan 2024 at 18:44:12
    Re: Set Text field value from Combo box selection in a Form

    The Item of the form is the SharePoint Request List, which contains lots of form data such as name , address, contacts, region and segment.

    The Region_Segment list contains the Regions to Segments mapping as above and this is the Items of the Regions combobox (or could just be a dropdown).

     

    The Segment Card Update attribute = txtSegment.Text.

    The Segment Card Default attribute = ThisItem.Segment

    The Segment field value, txtSegment default attribute = comboRegion.Select.Segment.

     

    The above works fine if you do not ever need to change the value entered in the Segment field, but this is not true in most cases, it needs to be changed.

    So what happens after I needed to amend Segment to Segment 1 - 123 and click Save

    markliam_0-1704998052395.png

    It saves the value to the datasource, however it puts the default value back to the previous value based on the Region selection, this should not happen because now if I went back in to edit the form the value in Segment would need to be updated again !, because if i didn't change it then the source would be updated back to Segment 1, and in any case its a terrible user experience to be showing the incorrect value in the form compared to the data source.

    markliam_1-1704998168137.png

    Does this make more sense now as to what the problem is ? 

     

    I think i need to have something on Change to ensure in Edit Mode when the values have been set, only update ThisItem.Segment if there is a change in txtSegment.Text , and this could happen if the user was to change the Region to a region that is in Segment 2 for example, OR if the user changed text in the txtSegment input text box.

    But cant get it to work..

     

     

     

  • markliam Profile Picture
    29 on 11 Jan 2024 at 16:42:46
    Re: Set Text field value from Combo box selection in a Form

    Hi @WarrenBelz 

     

    No that's not it.

    it's simpler than that.

    Just allow me to set the default value of Field 2 based on Field 1 selection i.e. from a lookup list/datasource.

    Also allow me to change that Field 2 default value once it is set to whatever I like. e.g. I might need to append the text that was entered in Field 2 with more information than was set by the default selection.

     

    The logic is straightforward, just seems to be rather hard to implement in PowerApps!

     

     

  • WarrenBelz Profile Picture
    149,102 Most Valuable Professional on 11 Jan 2024 at 12:06:02
    Re: Set Text field value from Combo box selection in a Form

    Hi @markliam ,

    This is more about the Item of the Form allowing the Text Box to show the saved data when you require it (so Parent.Default is the current saved field value) and show the Combo Box reference also when required. I am a bit confused about your logic now. What is the Item of the Form ?

  • markliam Profile Picture
    29 on 11 Jan 2024 at 10:39:07
    Re: Set Text field value from Combo box selection in a Form

    Hi @WarrenBelz 

     

    That doesn't quite work because when you save it and form goes back to View mode then the value appears as the Segment from the lookup list, even though it has been changed manually in the "Request" list.

     

    Even using this IF statement on Default of the text box- If(editMode,comboRegion.Selected.Segment,Parent.Default)

    when you go back into Edit mode it changes the value back to the Segment as per Region selection, which wouldn't be correct, it should just keep the value as entered into the Request list until edited again.

     

    Feel like its nearly there but just not getting where exactly to put the code to ensure the Segment field keeps the value as saved to the datasource "Request" list i.e. ThisItem.Segment in default of Segment Datacard but also allows to be changed from a change of the Region selection AND also then can be manually edited too.

     

    Is it on change of the Region field I need to drive the Segment value too? 

  • WarrenBelz Profile Picture
    149,102 Most Valuable Professional on 11 Jan 2024 at 10:21:04
    Re: Set Text field value from Combo box selection in a Form

    Hi @markliam ,

    Make the Default of the Text Box

    ComboBoxName.Selected.Segment

    and the user can change it if required.

     

    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

     

  • markliam Profile Picture
    29 on 11 Jan 2024 at 10:15:33
    Re: Set Text field value from Combo box selection in a Form

    Hi @WarrenBelz  Thanks for this and works perfect for this particular use case where the text field is view only.

     

    I also have use cases where I need to allow the users to edit the text field value, as the value may need amending.

    e.g. A Person is selected which populates an email field and a job title field , but the email or job title may need to be edited before saving.

     

    In our above example with Regions and Segments I assume cannot use the comboRegion.Selected.Segment as default data value of the Segment field, as this is why it keeps getting reset to blank without the approach you have advised?

    then what's the best way to manage the Region and Segment DataCard / Data Values to allow Segment value auto populate based on Region selection AND also allow the Segment text to be edited and saved. 

     

    Thanks! 

  • WarrenBelz Profile Picture
    149,102 Most Valuable Professional on 11 Jan 2024 at 00:10:16
    Re: Set Text field value from Combo box selection in a Form

    Hi @markliam ,

    The easiest way would be to set the DefaultSelectedItems of your Combo Box to contain it. I am guessing your Combo Box Items here and assuming it displays the Region field which is Text in the data source and also called Region.

    {
     Region: ThisItem.Region,
     Segment: 
     LookUp(
     SPList,
     Region = ThisItem.Region
     ).Segment
    }
     
    

     

    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

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading started