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

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create a file from all...
Power Automate
Unanswered

Create a file from all detail answers of a form using a loop

(0) ShareShare
ReportReport
Posted on by 7

Hello together,

i have the following use case:

Employees can submit a forms form (about 30 questions). From all the detailed answers i want to create a file which i can e.g. add to a list entry in sharepoint. I don't want to create a file by manually inserting all the answers line by line but iterate over the response somehow. In this way, the maintenance of the code is better because if i add new questions to the form or delete questions i don't have to add/delete these lines in my file because the file is then always generated by a loop over all the existing questions. 

 

This is my current status of work (Don't want to do it this way):

ToWag_0-1709285094899.png

 

Does sb have a better way?

Thanks in advance 🙂

Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,515 Super User 2026 Season 1 on at

    This flow retrieves the questions and answers and combines them into an array of corresponding objects:

     

    Chriddle_1-1709294022356.png

     

     

    Send an HTTP request to SharePoint

    Since the questions are not included in the response details, you have to get them with a request to Form API.

     

    Site Address: https://forms.office.com/

    Method: GET

    Uri: /formapi/api/forms('@{concat(triggerBody()?['resourceData']?['formId'])}')?$expand=questions

     

    Select

    From

    The first 2 properties of "Get reponse details" are skipped, because they are metadata (responder and submitDate) and should be handled seperately, iof needed.

     

     

    skip(
    	xpath(
    		xml(json(concat('{"Root":',body('Get_response_details'),'}'))),
    		'/*/*'
    	),
    	2
    )

     

     

    Map Question

     

     

    xpath(
    	xml(json(concat('{"Root":{"Item":',body('Send_an_HTTP_request_to_SharePoint')['questions'],'}}'))),
    	concat(
    		'string(//Item[id="',
    		xpath(
    			item(),
    			'name(/*)'
    		),
    		'"]/title)'
    	)
    )

     

     

    Map Answer

     

     

    xpath(
    	item(),
    	'string(/*)'
    )

     

     

     

     

    Result:

     

     

    [
     {
     "Question": "Test Question 1",
     "Answer": "Anser 1a"
     },
     {
     "Question": "Test Question 2",
     "Answer": "Answer 2 a"
     }
    ]

     

     

     

    From here you can easily reformat it to your liking.

    E.g.

    Chriddle_2-1709294443969.png

    Select 2

    From

     

     

    body('Select')

     

     

    Map

     

     

    concat(item()['Question'], ': ', item()['Answer'])

     

     

     

    Compose

     

     

    join(body('Select_2'), decodeUriComponent('%0A'))

     

     

     

    Chriddle_3-1709294614804.png

     

  • ToWag Profile Picture
    7 on at

    Hello @Chriddle ,

    at first thanks for you detailed answer and sorry for my late response. I tried to insert your code into my flow but unfortunately i get an error massage when it comes to the first Select action. "The input parameters of the "Select" process contain invalid expressions. Correct invalid expressions for the input parameters of the "Select" process." At this point i am lost because i am not able to change you code in a way it makes sense. The skip function seems to work since the error massage appears when i insert the stuff for Map Question and Map Answer. Maybe you can help?

    Thanks in advance.

  • Chriddle Profile Picture
    8,515 Super User 2026 Season 1 on at

    Sure, if you show me more details

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 237 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 173 Super User 2026 Season 1

#3
Kalathiya Profile Picture

Kalathiya 95 Super User 2026 Season 1

Last 30 days Overall leaderboard