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

Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

I use Power apps on a Shaerpoint form. I want to make a button that can reset combo Box fields and Calendar fields, and save the reset values.

I have two date fields called Start date and stop date, as well as combo Box fields that contain 3 categories (stop, Start, wait ".
With the push of a button in PowerApps, I want these to be set back to a predefined value.
Any idea how this is solved?

6 REPLIES 6
v-yutliu-msft
Level 10

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Hi @TrulsB ,

Could you describe more clearly about "combo Box fields that contain 3 categories (stop, Start, wait)"?

Could you tell me the fileds' data type that you want to reset?

I assume that the 'start date' and 'stop date' is date type, the combo box field is a choice field whose choice is "stop, start, wait".

I've made a similar test for your reference:

Firstly, unlock three controls, set thieir Reset :true and set their default value.

Set the datepicker's DefaultDate: "2019/5/1"  (a specific date)

Set the combo box's DefaultSelectedItems: ["wait"]  (one of its choice value)58_LI.jpg

 

Since you cannot reset controls that are within a Gallery or Edit formcontrol from outside those controls, you could try these two ways:

1)The controls are inside a form.

Set the button's OnSelect: 

ResetForm(Form1);SubmitForm(Form1)

2)The controls are outside the form

Set the button's OnSelect: 

Reset(DatePicker1);
Reset(DatePicker2);
Reset(ComboBox1);
Patch(datasource,Defaults(datasource),
{'start date'Smiley Very HappyatePicker1.SelectedDate,'stop date'Smiley Very HappyatePicker2.SelectedDate,status:ComboBox1.Selected}
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

 

 

TrulsB
Level: Powered On

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Hi,

the ComboBox is field called "Status" and this field is a lookup field in sharepoint, that are connected to another list.  So far there is onlye 3 items in the list, that are "Stop", "Start", "Wait" - and more statuses are coming later. 

 

The stop/start field is "Date" field in sharepoint.    I also have the last field that is a field for a selected user. 

 

I need to reset this values to default and save it back to Sharepoint, with the default values both for the Statsus field (lookup), start,stop fields and the user. 

 

v-yutliu-msft
Level 10

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Hi @TrulsB ,

Is the last field a choice field and its choices are users' name?

 

Best regards,

Community Support Team _ Phoebe Liu

TrulsB
Level: Powered On

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Hi, 

the last field for username is a "person or group" field from Sharepoint. 

TrulsB
Level: Powered On

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Resetting the fields is inside a Sharepoint form. I have tried various combinations without success in resetting the fields.

The fields have a value first and are saved to Sharepoint. When we open the form again with the appropriate data in the fields in edit mode, then the need is that I should be able to click the button for "Reset" to change the data in this way:

-Start date is set back to today's date
-End date is set blank
-The Status Field (ComboBox) is set back to the preset value
-User (person/Group) field is set blank
-Then the data form should be saved back to Sharepoint
-The form should be closed

When this item is opened again in view or edit mode, then there is the new data to be displayed.

I have followed the advice given in the article without success in achieving this functionality. I gladly welcome any new proposals.

v-yutliu-msft
Level 10

Re: Reset of values in combo box and calendar/date field in Sharepoint form using Power apps

Hi @TrulsB ,

Do you want the form to display a specific updated item firstly and then display another item?

Since the edit form's item has been set to a specific updated item, the control's default value will be also binging with it.

So I'm afraid it's not supported to make it directly currently in PowerApps.

I came up with two alternatives for your reference:

1)Add an item in the sharepoint list, start:Today's data, stop: blank,status: wait(example),last:blank

Set the form's Item:

If(IsBlank(test),Gallery2.Selected,Last(test510))

Set the reset buttom:

Set(test,"b")

Set the submit form's OnSelect:

SubmitForm(Form1)

2)not put the controls inside a form.

Add two datapickers, two combo boxes

Set the datapicker's DefaultDate:

If(IsBlank(test),Gallery2.Selected.start,Today())

If(IsBlank(test),Gallery2.Selected.start,"")

Set the combo box's DefaultSelectedItems:

If(IsBlank(test),Gallery2.Selected.status,{Value:"wait"})

If(IsBlank(test),Gallery2.Selected.status,{DisplayName:""})

Set the Reset button:

Set(test,"b")

 

 

 

Best regards,

Community Support Team _ Phoebe Liu