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

PowerApps unable to make custom button to reset data to NewForm

Hi,

I just want to ask, I have a custom PowerApps form, with 2 buttons Submit and Reset. If I am in the Edit mode of existing item, change some fields, click Reset , it does what I want which is reset back to the original data before the changes. But in New mode, fill in some data, the Reset does not reset to the new form even I have in onSelect of the Reset button as

if (SharePointForm1.Mode=1, NewForm(SharePointForm1), ResetForm(SharePointForm1))

 

I even tried with a separate button just for New mode, with onSelect as NewForm(SharePointForm1), enter some data, click it, it does nothing.

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
tchin-nin
Level 10

Re: PowerApps unable to make custom button to reset data to NewForm

Hi @Orchid,

 

The ResetForm() function reset the form to his DefaultMode property. So you have to add some logic on the property. I would set a variable when the form is open defining what is the current mode, and change the DefaultMode of the form according to this variable, so the ResetForm function will reset the form in the current mode.

 

SharePointIntegration.OnEdit :Concurrent(
    Set(
        currentMode,
        "edit"
    ),
    EditForm(SharePointForm1)
)

SharePointIntegration.OnNew :
Concurrent(
    Set(
        currentMode,
        "new"
    ),
    NewForm(SharePointForm1)
)

SharePointForm1.DefaultMode : 
Switch(
    currentMode,
    "new",
    FormMode.New,
    "edit",
    FormMode.Edit
)

ResetButton.OnSelect :
ResetForm(SharePointForm1)

Théo

View solution in original post

4 REPLIES 4
tchin-nin
Level 10

Re: PowerApps unable to make custom button to reset data to NewForm

Hi @Orchid,

 

The ResetForm() function reset the form to his DefaultMode property. So you have to add some logic on the property. I would set a variable when the form is open defining what is the current mode, and change the DefaultMode of the form according to this variable, so the ResetForm function will reset the form in the current mode.

 

SharePointIntegration.OnEdit :Concurrent(
    Set(
        currentMode,
        "edit"
    ),
    EditForm(SharePointForm1)
)

SharePointIntegration.OnNew :
Concurrent(
    Set(
        currentMode,
        "new"
    ),
    NewForm(SharePointForm1)
)

SharePointForm1.DefaultMode : 
Switch(
    currentMode,
    "new",
    FormMode.New,
    "edit",
    FormMode.Edit
)

ResetButton.OnSelect :
ResetForm(SharePointForm1)

Théo

View solution in original post

Orchid
Level: Powered On

Re: PowerApps unable to make custom button to reset data to NewForm

Hello @tchin-nin

 

Thank you for the explanation. But sorry I am very new to PowerApps and only self learnt. I am not really sure where should I put your code in. I tried to put at the FormScreen1 OnStart, but it doesn't like it. Please advise.

 

 

Orchid
Level: Powered On

Re: PowerApps unable to make custom button to reset data to NewForm

Hello @tchin-nin

 

Ah I think I understand what you meant earlier, I just need to put it likePowerApps properties.png

 

 

Orchid
Level: Powered On

Re: PowerApps unable to make custom button to reset data to NewForm

Hello @tchin-nin

 

It works great! Thank you very much.

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 (5,115)