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

Reset dropdpown does not work in edit form

Hi

 

I'm trying to reset a dropdown based on selection of another dropdown. I noticed this works only in Newform but not in Editform if the 2nd dropdown already has some data saved before. This is how I'm resetting the 2nd dropdown. In the onchange event of the first dropdown, I set a variable value

UpdateContext({ResetD2:true});UpdateContext({ResetD2:false})

 

I set the Reset function in the 2nd dropdown to the variable ResetD2.

 

Any workaround?

 

Thanks


Accepted Solutions
Community Support Team Rank
Community Support Team

Re: Reset dropdpown does not work in edit form

Hi @Rajesh

Do you want to reset the Combo Box when the Edit form is on Edit mode as that in NewForm?

Based on the formula you provided, I have made a test, the issue is confirmed on my side.

The Reset() function or Reset proeprty is used to reset the Control (e.g. Combo Box control) to the default value.

When you edit a record within the Edit form (The Edit form is in Edit mode), the Combo Box control would have a default selected value, so when you reset the Combo Box control (On your side, it is the second Drop down), it would reset your Combo Box to the original status with the default value selected.

As an alternative solution, you could consider clear the default selected value within your Combo Box. I have made a test on my side, please take a try with the following workaround:8.JPG

Set the OnVisible property of the first screen of your app to following:

Set(ResetSecondCombo, Blank())

Set the OnChange property of the first Combo Box control to following:

Set(ResetSecondCombo, Blank());
Set(ResetSecondCombo, true)

Set the DefaultSelectedItems property of the second Combo Box control to following:

If(
!IsBlank(ResetSecondCombo),
{},
Parent.Default
)

Best regards,

Kris


All Replies
Microsoft Employee

Re: Reset dropdpown does not work in edit form

Hello @Rajesh,

I would suggest to use the Reset function instead of setting the Rest properties to true and false: Reset(MySecondDropDown)

Please also note that Resetting a control disregards the currently selected value and then selects the default value. Since the DropDown default value is bound to the edited field in Edit form, that value will be automaticalyl shown after the reset. In another words, control reset in Edit form is for canceling all the edit changes and reverting to the previous value in the form. I would suggest revising the intended behavior.

Rajesh
Level: Powered On

Re: Reset dropdpown does not work in edit form

Hi

 

Thanks for the reply. I've tried using the Reset function and the behaviour is same as that of Reset properties. It works for NewForm as there's no previously saved data, but for edit form it defaults to the previously saved value for the control as you mentioned. Is there no way to clear the value as some of the subsequent actions on the form are based on answers selected to the previous questions i.e. Answers to Q1 drives choices in Q2 which in turn drives other questions

Microsoft Employee

Re: Reset dropdpown does not work in edit form

If you're using DropDown control (not CmoboBox control) in Edit form and don't want it to be bound to the form source then you need to ensure it's "Default" property is empty. In that case, Reset will clear the content. If you're using a ComboBox control (default control used in forms) then make sure it's "DefaultSelectedItems" property is not bound to a form field (is empty). You may need to unlock the parent card to do that.

Rajesh
Level: Powered On

Re: Reset dropdpown does not work in edit form

Setting DefaultSelectedItems to blank is not an option as that would lead to not showing the earlier saved value by the user when an user edits the item. My requirement is when the user edits the item, show the earlier saved values for dropdown 1 and 2. If the user changes value in dropdown 1, then reset the dropdown 2 and blank the selection. Currently reset function works only in new form but not edit form and it defaults to the earlier saved value

 

 

Microsoft Employee

Re: Reset dropdpown does not work in edit form

As mentioned before, the Reset function is not supposed to erase the content of the ComboBox. In order to achieve the intended behaviour, you could bind the DefaultSelectedItems conditionally to the field values (in order to maintain the Edit functionality) and then to erase it after the user interacts with the ComboBox. Something like:

Screen1.OnVisible=Set(ff, FieldValue)

ComboBox2.DefaultSelectedItems=ff

ComboBox1.OnChange=Set(ff,[]);Reset(ComboBox2)

 

Hope that helps.

Community Support Team Rank
Community Support Team

Re: Reset dropdpown does not work in edit form

Hi @Rajesh

Do you want to reset the Combo Box when the Edit form is on Edit mode as that in NewForm?

Based on the formula you provided, I have made a test, the issue is confirmed on my side.

The Reset() function or Reset proeprty is used to reset the Control (e.g. Combo Box control) to the default value.

When you edit a record within the Edit form (The Edit form is in Edit mode), the Combo Box control would have a default selected value, so when you reset the Combo Box control (On your side, it is the second Drop down), it would reset your Combo Box to the original status with the default value selected.

As an alternative solution, you could consider clear the default selected value within your Combo Box. I have made a test on my side, please take a try with the following workaround:8.JPG

Set the OnVisible property of the first screen of your app to following:

Set(ResetSecondCombo, Blank())

Set the OnChange property of the first Combo Box control to following:

Set(ResetSecondCombo, Blank());
Set(ResetSecondCombo, true)

Set the DefaultSelectedItems property of the second Combo Box control to following:

If(
!IsBlank(ResetSecondCombo),
{},
Parent.Default
)

Best regards,

Kris