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.
Region | Segment |
Region 1 | Segment 1 |
Region 2 | Segment 1 |
Region 3 | Segment 1 |
Region 4 | Segment 2 |
Region 5 | Segment 2 |
Region 6 | Segment 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 ?
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.
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..
You are correct that it may need some sort of variable triggered OnChange and make the Default conditional on it being false.
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
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.
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..
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!
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 ?
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?
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
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!
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
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473