Check the control type and where it sits
Use a test canvas app with classic Drop down, Text input, Combo box and Edit form controls. The first three examples use only made-up values stored in the app's memory. The form examples need your own approved test SharePoint list. These exercises are based on documentation; Quintera did not run them in your environment.
Place the first three controls and their buttons directly on a screen, outside forms and galleries. Microsoft limits Reset(childControl) to formulas within the same form or gallery when the target is inside one. A button outside a form can use ResetForm(formName) for the whole form. See the Reset reference.
Formulas below use English-locale commas between arguments and a single semicolon between actions. Power Fx separators depend on authoring locale; some language settings use semicolons between arguments and double semicolons between actions. Modern control properties can differ by version: check Microsoft’s current modern-control update guidance before adapting these examples.
Example 1: select a dropdown value from a button
Add a classic Drop down named ddStage. Set each property to its matching formula:
// ddStage.Items
["Queued", "Assigned", "Complete"]
// ddStage.Default
Coalesce(varStageDefault, "Queued")
// ddStage.AllowEmptySelection
false
Add a button labeled Assign. Set its OnSelect to:
Set(varStageDefault, "Assigned");
Reset(ddStage)
Preview the app, choose Complete, then select Assign. It should select Assigned. Choose Queued and press Assign again: it should return to Assigned even though the variable already holds that value. Calling Reset handles that second case.
Read the choice with ddStage.Selected.Value; do not try to assign to Selected.Value. The Set function changes a variable used by the input formula. Keep the three text values exactly the same as those in Items. With AllowEmptySelection = false, this control always selects something, so setting a blank default will not clear the selection. See the classic Drop down properties.
Example 2: clear a search box or restore a note
Add a classic Text input named txtSearch. Set Default to "" and HintText to "Find a work item". Add a Clear button with:
// Clear button OnSelect
Reset(txtSearch)
Type Beacon and press Clear. The expected output txtSearch.Text is an empty string. Hint text may still appear, but it does not count as entered text. Use a label with Len(txtSearch.Text) to confirm the expected length is zero.
Now add txtNote, another classic Text input, with Default = "Confirm the due date". Give a Restore note button this formula:
Reset(txtNote)
Replace the note with Harbor review and press Restore note. The expected result is Confirm the due date, not an empty field. This difference comes from each control’s Default. Clearing an input does not delete a record from SharePoint. The classic Text input reference distinguishes Default, Text and HintText.
Example 3: supply matching records to a combo box
Add a classic Combo box named cmbClient. Add an Initialize example button with this OnSelect:
ClearCollect(
colArticleClients,
{ClientId: 101, ClientName: "Beacon Studio"},
{ClientId: 202, ClientName: "Harbor Works"}
);
Set(varClientDefaultId, 202);
Reset(cmbClient)
Configure the combo box:
// Items
colArticleClients
// DisplayFields and SearchFields, each
["ClientName"]
// SelectMultiple
false
// DefaultSelectedItems
Filter(colArticleClients, ClientId = varClientDefaultId)
Run Initialize example. The expected selection is Harbor Works. The filter returns a table of matching records with the same columns as Items. A label containing cmbClient.Selected.ClientId should show 202. A string such as "Harbor Works" alone does not include the fields that this record needs.
For a Clear client button, use:
Set(varClientDefaultId, Blank());
Reset(cmbClient)
None of the sample ClientId values is blank, so nothing should be selected. This example uses a small collection stored in the app. SharePoint Person, Choice and lookup columns need their own record structures; keep those structures rather than using this two-column sample. Sources: Combo box properties, Filter result types and ClearCollect.
Example 4: discard edits without changing the saved row
In an approved test SharePoint list named Article Work, create one made-up row with Title set to Beacon kickoff. Connect the list to your test app. Add a gallery named galArticleWork and a classic Edit form named frmArticleWork. Set these properties:
// galArticleWork.Items
'Article Work'
// frmArticleWork.DataSource
'Article Work'
// frmArticleWork.Item
galArticleWork.Selected
// frmArticleWork.DefaultMode
FormMode.Edit
Use Edit fields to add Title to the form. Keep the generated card's default and update formulas. Select the made-up gallery row. Add an Edit button with EditForm(frmArticleWork) and a Discard changes button with:
ResetForm(frmArticleWork)
Press Edit, change Title to Harbor review, then discard. Expected: Title returns to Beacon kickoff, and the saved SharePoint row remains unchanged because nothing was submitted. The form must have a selected Item; an Edit form with no record is not a usable new-entry screen. See form DataSource and Item properties and Microsoft’s form walkthrough.
Example 5: restart an intake form and reset only after success
Reuse the test form as a new-item intake example. Add a New item button with NewForm(frmArticleWork). Press it, then type a synthetic title. For a Start again button that discards this unsaved draft and stays ready to create, use:
ResetForm(frmArticleWork);
NewForm(frmArticleWork)
Expected: source defaults return and the form is in New mode. ResetForm alone changes a New form back to Edit. New mode ignores Item and uses data-source defaults; these are not necessarily all blank. See the form functions.
For this intake version, set these three properties to handle saving:
// Save button OnSelect
SubmitForm(frmArticleWork)
// frmArticleWork.OnSuccess
Notify("Work item saved.", NotificationType.Success);
NewForm(frmArticleWork)
// frmArticleWork.OnFailure
Notify("Not saved. Keep your draft and check the form error.", NotificationType.Error)
Add an error label with Text = frmArticleWork.Error. A successful save should create one row and open a new draft. A rejected save should keep the draft and show an error. Put the action that starts the next draft in OnSuccess, not immediately after SubmitForm on the button. This example is for entering items one after another. An app used only for editing should choose what happens after its own successful save. The form walkthrough explains success and failure handling.
Check the cases that usually get missed
- Repeat each button after the user manually changes the value. Check both a changed default variable and an unchanged one.
- For the combo box, initialize, clear, then initialize again. Confirm the displayed name and numeric ID match.
- For the form, test existing-record edit, new draft, discarded draft and rejected submission separately.
- Try leaving a required field empty in the test list to check a rejected save. Do not break a production connection to force a failure.
- Give buttons clear names: Clear search, Discard changes and Start again do different things.
If a form still behaves unexpectedly, record its Mode, Item ID, control type and relevant default formula before adding more reset calls. A save-error investigation is the next step when the reset behavior is correct but the write fails.