web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Power Apps - Resetting DataCardValue fields within a form

(4) ShareShare
ReportReport
Posted on by 8
Hello,  I hope someone knows the answer to this.  I was reading a post from the forum on how to do this and it appears that Microsoft has changed things.  As of today, how do you clear DataCardValue fields within a form attached to a gallery?  I've tried the things that I read (e.g. Reset(DataCardValue), but it doesn't work.  I'm trying to use a Button to clear the fields with the following code for the On Select Property:
 
On Select
Reset(DataCardValueDateCleaned);
Reset(DataCardValueCleanedBy);
Reset(DataCardValueDateMaitained);
Reset(DataCardValueMaintainedBy);
Reset(DataCardValueDateApproved);
Reset(DataCardValueApprovedBy);
Reset(DataCardValueStatusNotes);
SubmitForm(CrownFormRmMakeReady)
 
I get the following error message: "The reset button can only be used with a resettable control. Controls within a form or gallery control can only be reset from within the same form or gallery template".  Okay ... how do you do that?
 
The gallery I'm using doesn't have a reset property.  I've tried setting the form's "On Reset" property to true. None of the DataCardValue fields have a reset property.  I've selected the form when I inserted the button control.
 
I appreciate your help.  Mel.
I have the same question (0)
  • Verified answer
    Daivat Vartak (v-9davar) Profile Picture
    7,827 Super User 2025 Season 2 on at
    Power Apps - Resetting DataCardValue fields within a form
    Hello CU03030212-0,
     
    You're encountering a common issue when working with DataCardValue controls within a form that's nested inside a gallery in Power Apps. The error message is telling you that you can only reset these controls from within the context of the form or gallery template.
    Here's a breakdown of the problem and the correct approach:
     
    Understanding the Problem:
    • DataCardValue Context: DataCardValue controls are tied to the specific record being displayed in the form within the gallery. They don't exist independently.
    • Reset Scope: The Reset() function only works on controls that are directly within the same scope as the button (or other control) calling it.
    • Gallery Scope: The button you're using is outside the gallery's template scope, so it can't directly access the DataCardValue controls within the form.
     
    The Solution: Using a Context Variable and UpdateContext()
    The most reliable way to clear DataCardValue fields within a form nested in a gallery is to use a context variable and the UpdateContext() function.
     
    Here's how to do it:
    1. Add a Checkbox (or Similar Control) Inside the Gallery:
      • Inside the gallery template, add a Checkbox control (or any control that can store a Boolean value).
      • Name it something like chkReset.
      • Set its Default property to false.
    2. Modify the Button's OnSelect Property:
      • Modify the OnSelect property of your button to:
        Code snippet (Example)


        UpdateContext({resetFields: true});
    3. Modify the DataCardValue Control's Default Property:
      • For each DataCardValue control you want to clear, modify its Default property:
        Code snippet (Example)


        If(resetFields, "", ThisItem.YourFieldName)
      • Replace YourFieldName with the actual field name associated with the DataCardValue.
    4. Reset the Context Variable:
      • Add a Timer control to the screen (you can set its Visible property to false to hide it).
      • Set the Duration property of the Timer to 1.
      • Set the OnTimerEnd property of the Timer to:
        Code snippet (Example)


        UpdateContext({resetFields: false});
     
    • Set the Start property of the Timer to resetFields.
     
    Explanation:
    • Context Variable (resetFields):
      • The UpdateContext({resetFields: true}) sets the resetFields variable to true when the button is clicked.
    • Conditional Default Property:
      • The If(resetFields, "", ThisItem.YourFieldName) in the DataCardValue controls' Default property checks if resetFields is true.
      • If true, it sets the DataCardValue to an empty string (""), effectively clearing it.
      • If false, it displays the value from the current item in the gallery (ThisItem.YourFieldName).
    • Timer to Reset Context Variable:
      • The Timer control is used to reset the resetFields variable back to false after a short delay (1 millisecond). This ensures that the DataCardValue controls don't remain cleared indefinitely.
     
    Key Points:
    • DataCardValue Controls: You can't directly reset DataCardValue controls from outside the form or gallery template.
    • Context Variables: Context variables are used to pass information between controls within the same screen.
    • Timer Control: The Timer control is used to create a short delay and reset the context variable.
    • Testing: Thoroughly test your solution to ensure that the DataCardValue controls are cleared correctly.
     
    By using this approach, you should be able to clear the DataCardValue fields within your form nested in a gallery using a button click.
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Best Regards,
    Daivat Vartak

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
DAnny3211 Profile Picture

DAnny3211 296

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 137 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 87 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans