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.

60 REPLIES 60

For clarity:

I have tried the API call with each of the varying parameters:

  • formapi/api/[actual string for tenant id]/users/[actual string for user id/object]/forms('[actual string for form id]')/responses

  •  

    formapi/api/forms('[actual string for form id]')/responses

  • formapi/api/[actual string for tenant id]/users/[actual string for user id/object]/forms('[actual string for form id]')/responses('[actual string for response id')

  • formapi/api/[variable for tenant id]/users/[Variabel for user id/object]/forms('[variable for form id]')/responses

  • formapi/api/forms('[variable for form id]')/responses

All fail with the same "Unauthorized" error.

clh
Advocate I
Advocate I

Two things...

 

This is incorrect with the /responses part and putting the responseId in parentheses.

  • formapi/api/[actual string for tenant id]/users/[actual string for user id/object]/forms('[actual string for form id]')/responses('[actual string for response id')

DO NOT enclose the responseID in any quotes, single or double.  It is an integer value, not a string.  I.e., .../responses(16)   or whatever the responseId is instead of the 16.  (Still do use parentheses, but no quote marks.  FormID DOES get surrounded by single quotes/apostrophes inside parentheses.)

 

See this previous post that details exactly how all of the various values work...
https://powerusers.microsoft.com/t5/Building-Flows/forms-delete-all-responses/m-p/2446052/highlight/...

 

 

One other thing just occurred to me that could be tied to permissions.  If the account that the Automate is running under is not the same account that the Form was built under (the account that owns the form), I believe the user ObjectId needs to be the objectId of the account that owns the form, NOT the objectId of the account running the Automate.

And of course, the account running the Automate must have permissions to the Form.

 

But if the Automate is running under the same account that owns the form, then the user ObjectId would be the same anyway, and it would obviously have permissions to the form.

/formapi/api/@{outputs('TenantID')}/users/@{outputs('User_ID')}/forms('@{outputs('FormID')}')/responses

I'm storing the tenat id/user id/form id in compose just to avoid lengthy expressions. Also check the Site Address.

Only for the forms you have to give ('') and for the rest no () or ''

10b2404f-5bc2-434a-85ec-fa40790a7995.jpg


Please make sure to use in this format to give a shot ?

Verbatim:  /formapi/api/@{outputs('TenantID')}/users/@{outputs('User_ID')}/forms('@{outputs('FormID')}')/responses

MTMattManley_2-1712313661804.png

 

I tried both with and without the ' string containers around the TenantID and UserID and got the same results.

Results:  

MTMattManley_0-1712313020139.png

And I also triple checked my TenantID and my user ObjectID.

To add insult to injury, if I post the API to forms.microsoft.com as a GET - It returns the results.

https://forms.office.com/formapi/api/@{TenantID}/users/@{UserID}/forms('@{FormID}')/responses

 

Did your windows password have changed recently ?

Hey @MTMattManley 

Just double check the "Site Address" in the "Send an HTTP request to SharePoint" step is forms.office.com, not forms.microsoft.com.

Screenshot 2024-04-06 122057.png

If I swap to forms.microsoft.com, I get the same error you receive.

@GrahamKelly !

Thank you so much for taking the time to help me!   You have moved the donkey on the edge back to sanity!

You identified the problem and provided the solution!

ewfefwef
Advocate II
Advocate II

That is also what I provided in the screenshot. Glad you got it working.

ewfefwef_0-1712679639128.png

 

RedSnow_94
Frequent Visitor

Hi, sorry to jump in this thread. I have followed what has been listed here previously and it works great for myself - deleting the flow runs and any details in MS Forms for myself. However, when I get my colleagues to test by submitting a form I get an error message at the SharePoint Action "Unexpected response from the service
clientRequestId: 4d90af36-a92e-4a7d-90f4-cee1897527df".

 

I have hard coded the Tenant and Form IDs into compose steps, the User ID I am fetching dynamically by using the Form submitter's email to look up their profile in the Directory.

 

Any ideas where I might be going wrong?

 

Thanks

Steven

Did you try using your user id as you own the form and have access to delete the responses.

Sorry not quite sure what you mean - I can go into the Form responses and see my colleagues answers and delete them manually - if I hard code the User ID to always be mine, would that still allow deletion of other responses? I will try it and report back

The User object ID needs to be the object ID of the user account that hosts the form.  So yes, it is a static value.

I mentioned this in my earlier post:
https://powerusers.microsoft.com/t5/Building-Flows/forms-delete-all-responses/m-p/2690543/highlight/...

Thank you, I should have read the previous posts more closely, now that I've coded the UserID to me its working.

 

Follow up question - is there a way of automically clearing the flow run history? The reason I am clearing the form responses is because it could contain sensitive data. Although I would be the only person with access to the flow, I want to assure users that I can't see data they submit (any data will only be forwarded to their line manager). I can't use secure inputs as the form is used for many other uses - the sensitive part is only one branch of the whole system.

Bristolizer
Frequent Visitor

This string has been a fantastic read. We have been trying to get the deleting of form responses to work for several months with no success. We continue to get a 400 Unexpected response from the service error. I have tried this for both forms I own and group forms in Teams and I get the same error. I can paste the site address with uri into my browser and I get the responses. 

Could I be running into a security issue? 

 

Bristolizer_0-1716401624391.png

 

  • Make sure that the "User ID" is the object ID of the user account that owns the form, NOT the user ID of the user who submitted the form.
  • If the Power Automate is running under a different account than the account that owns the form, the account running the PA must still have permissions to the form.
  • For forms in Teams, that MIGHT (I don't know for sure) fall under "groups".  In that case, replace the /users/<userID> piece of the URL with /groups/<groupID>  where <groupID> is the object ID of the group that hosts the form.

Thank you for your response. I have attempted all of what you suggested and still get the 400 error message.

Just to try out.

May be create a new form and try to see if it works?

I appreciate that. Yes, I have been trying to get this to work and still get the 400 error message. I can put the full code as is in my browser and it will query the responses. It is very frustrating. I am curious if any has had this happen and found a work around or tried a different connector other than the Sharepoint HTTP request.

@Bristolizer, if we temporarily strip it back... try the 'SharePoint request' step without any variables and hardcode your tenancy, group/user and form id into the Uri.

 

So, if it's a group Form:

/formapi/api/TENANCY_ID/groups/GROUP_ID/forms('FORM_ID')/responses

 

Personal Form:

/formapi/api/TENANCY_ID/users/USER_ID/forms('FORM_ID')/responses

 

When you then run your flow, does it successfully complete?

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,368)