cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cfebvre
Level: Powered On

Preserve selected value of custom dropdown control after submit in edit mode

Hi all,

 

I've posted this problem before but didn't get a resolution. Going to try and explain myself a little better.

 

I have an App with a form screen that draws the majority of its data cards from a main Sharepoint list.

When using the basic fields that are generated upon linking the data source, the default behaviour of those fields is to preserve the choice that was selected by the user upon submitting the form.

So when a user edits that form, the choice they made previously is preserved.

This is great, and exactly what I need.

 

However, a couple of the fields I have use custom controls in order to draw data from different sharepoint lists. These are configured as dropdowns also, but they are generating their 'choices' from a list of 'single line text entries' in the secondary Sharepoint list (in other words, they are not a choice column in the Sharepoint list).

My app is set up this way so I can filter these datacards based on the choice made in other datacards on the form.

 

These custom dropdowns revert back to the first available entry (after filtering) after the form is submitted. It stores the correct choice in the main Sharepoint list upon submission, but upon editing the form, the choice has reverted back. 

 

Eg: User selects 'Week 13' in the 'Week Number' custom control dropdown.

App stores  'Week 13' in the main Sharepoint list upon user hitting submit button

App then reverts to 'Week 01' in the 'Week Number' custom control dropdown.

 

Because this is a custom datacard, it does not possess the DefaultSelectedItem property.

 

Has anyone come across this behaviour? Is there a way to preserve/store the choice made in a custom control datacard when the user comes back to edit the form?

 

Cheers!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
seadude
Level 10

Re: Preserve selected value of custom dropdown control after submit in edit mode

I've had something like this happen before. Can't quite remember how I solved it, but here is something to try:

- Rather than DefaultSelectedValue, try setting the Default property of the dropdown accordingly

- Collect the LastSubmitted form so you can set the Default using: First(colLastForm.weekNumber).weekNumber or the like.

Good luck!

View solution in original post

2 REPLIES 2
Highlighted
seadude
Level 10

Re: Preserve selected value of custom dropdown control after submit in edit mode

I've had something like this happen before. Can't quite remember how I solved it, but here is something to try:

- Rather than DefaultSelectedValue, try setting the Default property of the dropdown accordingly

- Collect the LastSubmitted form so you can set the Default using: First(colLastForm.weekNumber).weekNumber or the like.

Good luck!

View solution in original post

cfebvre
Level: Powered On

Re: Preserve selected value of custom dropdown control after submit in edit mode

Thanks so much @seadude !

I knew I was hovering around the solution, but your tip helped steer me in the right direction.

For reference to anyone else who might come across this post, here's the full solution I used.

 

To preserve the last selection in a submitted form for a specific dropdown, go to the 'Default' property of the DataCardValue of that dropdown and enter this formula:

[InsertFormName].LastSubmit.[InsertFieldName] <- This must be a Text value, not a choice column. If you try to enter a choice value Powerapps will give an error stating 'expects text value'.

 

For reference, my exact formula is:

StoryViewFormName.LastSubmit.HiddenWeekNo

 

Now, the tricky bit. It's very likely you want to preserve the last 'choice' a person made in a choice dropdown. But Powerapps wants a 'Text' value.

How annoying, right?

 

To get around this, you will need to create an additional column in your Sharepoint list that will be a duplicate of your 'choice' column, but it will be a 'single line of text' column instead.

 

Then you will add this new field into your powerapp.

 

For reference, I have two Week fields. 'WeekNo' is a choice field. 'HiddenWeekNo' is a plain text field.

The default property of 'HiddenWeekNo' is:

Text(WeekNoDataCardValue.SelectedText.Value).

As you can see, this duplicates the 'Choice' selected in WeekNo, and spits it out as Text in the HiddenWeekNo field.

 

Finally, you are now able to set the Default property of you Choice field (WeekNo in my case) as:

[InsertFormName].LastSubmit.[InsertFieldName] <- in my case, this is HiddenWeekNo, which is text.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,734)