cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Omar
Advocate I
Advocate I

forms delete all responses

It would be great to have an action that when triggered deletes a response or possibly all responses. Due to GDPR having data saved both in Forms and in SharePoint (if the form data is copied into SharePoint) is not ideal and there is currently no way to automate the deletion of the responses from within Flow. I know all of the responses within a form can be deleted from within the Forms action menu so having something similiar as an action within Flow would be great.

1 ACCEPTED SOLUTION

Accepted Solutions
60 REPLIES 60
v-yamao-msft
Community Support
Community Support

Hi @Omar,

 

Are you working with SharePoint forms? Do you want to delete the items in the forms using Microsoft Flow?

 

If yes, I am afraid that currently there is no available action can be used. Please consider submitting a request on Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, @Omar!

 

If you have already posted your idea to the Flow Community Ideas Forum then you need to post the URL to your idea’s thread as a reply to this thread and then "Accept as Solution" on that reply so other users may vote for your Flow Idea and identify the information easily.

 

Thank You!

 

-Gabriel
Flow Community Manager

- Gabriel
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager



Omar
Advocate I
Advocate I
MayureshT
New Member

Hi All,

Did anyone find how to deleted Microsoft Forms responses from excel using flow? 

WendyOx
New Member

This is not solved! The suggestion is just a request to Voice Ideas ... unmark as solved!

ewfefwef
Advocate II
Advocate II

Use Send HTTP Request to SharePoint Connector in Power Automate.

You need your TenantID, UserID and FormID(s).

See Azure Active Director or Powershell to get Tenant and UserIDs. The form URL shows the ID.

My flow deletes all responses from many forms each night.

I created a simple array FormID with Name & ID of all the forms. You could easily use a MS List or excel or whatever source you want to maintain for Form Name/IDs.

Loop the array and delete all responses.

You Parse the JSON (your array) inside the loop to be able to use the ID string variable in the HTTP connector. Makes it easy to read and understand the flow, I just prefer to an expression.

 

ewfefwef_0-1648103610484.png

 

Holy mother of all it does work your way !

the difference is i change

the Users/[Uservariable] for Groups/[GroupVariable]

 

using the sharepoint http request allows you to authenticate

 

Someone69_1-1650984685292.png

 

clh
Advocate I
Advocate I

The Send HTTP request solution has one problem, as mentioned in this Reddit post:

https://www.reddit.com/r/PowerPlatform/comments/111amhf/how_to_use_power_automate_to_delete_response...

 

It deletes ALL current responses in the form.

 

If the form gets used heavily where there's a high likelihood of multiple users submitting responses close together, or happens to submit something at the exact moment the flow runs to delete all responses, then some responses will get missed.

 

I discovered a way to delete THIS response, i.e., the specific individual response that's being handled by the current run instance of the Automate flow so that it doesn't impact other responses.  That is to add the Response Id in parentheses after the /responses part of the Uri.

To get the Response Id, use the trigger "When a new response is submitted" and Response Id is an output from that trigger.

 

clh_0-1676588825569.png

 

 

apacey
Regular Visitor

this did work until now, it returns with BadRequest 400 

{
  "status"400,
  "message""Unexpected response from the service\r\nclientRequestId: c9e203aa-61ee-4be6-9452-8041ab1dba8b",
  "error": {
    "message""Unexpected response from the service"
  },
  "source""sharepointonline-cc.azconn-cc-002.p.azurewebsites.net"
}

Still works for me.

Anonymous
Not applicable

I just wanted to follow (for future documentation purposes) that the API is picky, I got the above error when I used double quotes around the form_id, changing to using single quotes and the call works.

demzem
Frequent Visitor

HI @clh as a newbie, i am trying to get this to work - but i simply have add to list steps, then the http request to delete the matching ID in the form. Using the raw ID's added into the api string for tenant, user and form with ('xxxx') wrapper, should this work> i get the error mentioned above

You'll need to provide more details about what you're trying to do, maybe a screen shot of your flow.  I don't understand what you're asking.

Hi @apacey ,

Did you find a solution to make your flow work?

I tried a variety of different symbols before and after the FormID part of the Uri, but no luck:

1. Parentheses:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms(@{variables('FormID')})/responses


2. Parentheses and single quote:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms('@{variables('FormID')}')/responses


3. Parentheses and double quote symbols:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms("@{variables('FormID')}")/responses


4. No additional symbols:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms@{variables('FormID')}/responses


5. slash between "forms" and the formID:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms/@{variables('FormID')}/responses


6. Slash and parentheses and single quite marks:

/formapi/api/@{variables('TenantID')}/users/@{variables('UserID')}/forms/('@{variables('FormID')}')/responses

 

demzem
Frequent Visitor

Hi @ptstockley 
I did fix this yes! I saw that the error related to authentication, so stripped it back and rebuilt it as the below.. works like a dream!

I need to go back and tidy the flow as i no longer need tenant id or user id variables... I like removing each form entry by ID with each iteration of the entire flow, just remove (Response ID) from the below to delete all.

/formapi/api/forms('⁠FormID×⁠')/responses(⁠Response Id×⁠)

demzem_1-1699518744441.png

 

demzem_0-1699518618307.png

 



Thank you for this! 🙂

In testing I think I noticed that the account running the flow, must have editing access to the form in order for the flow to succeed.

Perhaps this is obvious (to avoid deleting responses from non-owners), but i haven't seen it explicitly stated.

clh
Advocate I
Advocate I

I'm still not sure I entirely understand what these last few posts are trying to do but if you're hard coding the values instead of using variables, then it would look like this...

 

If...

  • tenantId = abc123-def456
  • userId = xyz789-ghf789
  • formId= qwerty345-mnop987
  • ResponseId = 7

then you get this for the Uri...

formapi/api/abc123-def456/users/xyz789-ghf789/forms('qwerty345-mnop987')/responses(7)

I.e., ...

  • tenantId, userId, and formId are just plain strings.
  • tentantId and userId are NOT surrounded by any quotes within the Uri (either single or double).
  • formId IS surrounded by SINGLE quotes (apostrophes) and the parenthesis in the Uri.
  • ResponseId is a numeric value and, again, is NOT surrounded by any quotes, just within parentheses.  But to really make this work you'll need to use the output of the trigger and I don't see why this would ever be hard coded anyway.

If you want to delete ALL responses, as the original post in this thread indicated, simply remove the parenthesis and ResponseId from the end.  I.e., ...

formapi/api/abc123/users/xyz789/forms('qwerty456')/responses

 

I guess one thing I didn't mention in my original post about deleting individual responses was where to actually get the ResponseId from.  Use the "When a new response is submitted" trigger and the ResponseId is an output from that trigger.  I've edited my previous post to include this.

 

And yes, the account that runs the flow must have permissions to the form.  That's true of ANYTHING in Power Automate, so yes, it's obvious and shouldn't need to be stated.  (E.g., a flow can't work with a SharePoint list if the account running the flow doesn't have access to the SharePoint list.)  In most cases, people are likely running the flow from the same account that hosts the form.  If the flow is running in a different account, then yes, that account must be granted permissions to the form.

 

 

demzem
Frequent Visitor

Hi @clh for the reply, so the problem was that the tenant id and user id caused errors.
So basically I removed them and it now works brilliantly! 🙂
Not sure why they would be needed in some environments and not others , but I guess we will find out when they stop working 😞

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (3,199)