cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Send pdf created after submiting form in attachment by microsoft flow

Hi,

 

Here is how my app with several flows works:

1. I have a custom form app linked to sharepoint list.

 

2. After submitting form, "createPDF" flow automatically create pdf raport with unique name in sharepoint folder.

In OnSave property of SharePointIntegration I typed following code:

createPDF.Run(HTMLtext.HtmlText, uniqueName.Text);
SubmitForm(Form1)

Where HTMtext is just HTML code, and uniqueName.Text is the name of created pdf.

 

3. Next flow "Approval flow" is triggered when an item is created in sharepoint list, so basically just after submitting form.

It has several layers of people responsible of approve. On the last step, I need to send email to external person. with created before pdf raport in attachment. 

 

The name of created raport is the same as unique, non-editable, uniqueName in each submited form, so I tried to link somehow this dependency in flow, but without succes. I also tried to filter folder with pdfs by this uniqueName to get pdf raport file content in flow, but also without succes.

 

Is there any way to do it?

 

Thank you for all your help

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi @golabem ,

I have made a test on my side, please consider configure your flow's configuration as below:

Your 'createdPDF' flow should be configured as below:10.JPG

Within the "HTTP" action, set the Body field to following:

{
  "PDFFileContent": @{body('Get_file_content')},
  "ListItemID": @{triggerBody()['HTTP_Body']}
}

Note: The @{triggerBody()['HTTP_Body']} represents the HTTP_Body parameter generated via clicking the "Ask in PowerApps" dynamic content. The @{body('Get_file_content')} represents the File content dynamic content from above "Get file content" action.

 

Your "Approval flow" should be configured as below:8.JPG

 

9.JPG

Within the "When a HTTP request is received" trigger, set the "Request Body JSON Schema" field to following JSON Schema:

{
    "type": "object",
    "properties": {
        "PDFFileContent": {
            "type": "object",
            "properties": {
                "$content-type": {
                    "type": "string"
                },
                "$content": {
                    "type": "string"
                }
            }
        },
        "ListItemID": {
            "type": "string"
        }
    }
}

Within the "Get Item" action, set the Id field to following formula:

int(triggerBody()?['ListItemID'])

Within the "Send an email" action, set the Attachments Content -1 field to following formula:

base64ToBinary(triggerBody()?['PDFFileContent']?['$content'])

set the Attachments Name -1 filed to a specific PDF file name.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

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

View solution in original post

8 REPLIES 8
Highlighted
Responsive Resident
Responsive Resident

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi,

 

I think this may help you. https://powerusers.microsoft.com/t5/Using-Flows/Flows-take-a-long-time-before-they-are-triggered/td-...

 

If this answers your question mark it as verified,

Regards,

#Pavan Kumar Garlapati

Highlighted
Community Support
Community Support

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi @golabem ,

Could you please share a bit more about your scenario?

Does the "createPDF" flow create a PDF file with unique name in your SP Library?

 

Based on the issue that you mentioned, I think issue may be related to that -- the "Approval flow" has been fired successfully, and are going to send email to external person (last step), but the "createPDF" flow has not been finished. In other words, the "Approval flow" has gone to the last step, but the PDF report file (create via "createPDF" flow) has not been created in your SP Library/folder.

 

As an alternative solution, I think you could consider call the "Approval flow" within your "createPDF" flow. I have made a test on my side, please consider take a try with the following workaround:

1. Remove the "When an item is created" trigger of SharePoint from your "Approval flow", instead, add a "When a HTTP request is received" trigger as the Trigger. Then save your "Approval flow", and then copy the generated HTTP POST URL as below:6.JPG

2. Edit your "createdPDF" flow, add an additional "HTTP" action at the last action step as below:2.JPG

3. Within your PowerApps, set the OnSave property of the SharePointIntegration control to following:

Set(HTMLCode, HTMLtext.HtmlText);Set(UniqueName, uniqueName.Text);
SubmitForm(Form1)

Set the OnSuccess property of the SharePointForm1 to following:

createPDF.Run(HTMLCode, UniqueName, SharePointForm1.LastSubmit.ID);     /* <-- Add this formula. SharePointForm1.LastSubmit.ID formula is used to pass the value to the HTTP_Body parameter in above "createdPDF" flow  */
ResetForm(SharePointForm1);
RequestHide()

Set the OnNew property of the SharePointIntegration control to following:

Set(HTMLCode, Blank());Set(UniqueName, Blank());
NewForm(SharePointForm1)

4. Within your "Approval flow", you could retrieve the HTTP_Body value from your "createdPDF" flow in your "When a HTTP request is received" trigger, then you could get the List Item ID value of the submitted form data. Based on the retrieved List Item ID, you could use the "Get Item" action of SharePoint to get the submitted record in your SP List.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Send pdf created after submiting form in attachment by microsoft flow

@v-xida-msft 

Yes, "createPDF" flow create a PDF file with unique name in my SP document library.

 

I make changes you suggested and it solve for sure issue with finishing flows in right order, but I still can't get dynamic content of PDF raport to attach in email. I think problem is I "get item" of sharepoint last submited form in list, not in particular SP document library where pdf file was saved.

I attach some screenshots to be more clear

2019-09-03_10-09-06_1.png

 

2019-09-03_10-11-48_2.png

 

 

Highlighted
Community Support
Community Support

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi @golabem ,

I have made a test on my side, please consider configure your flow's configuration as below:

Your 'createdPDF' flow should be configured as below:10.JPG

Within the "HTTP" action, set the Body field to following:

{
  "PDFFileContent": @{body('Get_file_content')},
  "ListItemID": @{triggerBody()['HTTP_Body']}
}

Note: The @{triggerBody()['HTTP_Body']} represents the HTTP_Body parameter generated via clicking the "Ask in PowerApps" dynamic content. The @{body('Get_file_content')} represents the File content dynamic content from above "Get file content" action.

 

Your "Approval flow" should be configured as below:8.JPG

 

9.JPG

Within the "When a HTTP request is received" trigger, set the "Request Body JSON Schema" field to following JSON Schema:

{
    "type": "object",
    "properties": {
        "PDFFileContent": {
            "type": "object",
            "properties": {
                "$content-type": {
                    "type": "string"
                },
                "$content": {
                    "type": "string"
                }
            }
        },
        "ListItemID": {
            "type": "string"
        }
    }
}

Within the "Get Item" action, set the Id field to following formula:

int(triggerBody()?['ListItemID'])

Within the "Send an email" action, set the Attachments Content -1 field to following formula:

base64ToBinary(triggerBody()?['PDFFileContent']?['$content'])

set the Attachments Name -1 filed to a specific PDF file name.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

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

View solution in original post

Highlighted
Community Support
Community Support

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi @golabem ,

Have you solved your problem?

 

Based on the needs that you mentioned, I think the solution I provided above could achieve your needs. Please take a try with it, check if your issue is solved.

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Send pdf created after submiting form in attachment by microsoft flow

@v-xida-msft 

Thank you very much for your profesional answer, I really appreciate this. 

 

Yes, it works, but has one glitch - raport sent by email in attachment can be open by AdobeReader but is not pdf type, and it doesnt look profesional. I copied exactly the same code you suggested. Is there any easy way to make it pdf type? 
Screenshot below:

2019-09-04_8-58-51_3.png

Highlighted
Community Support
Community Support

Re: Send pdf created after submiting form in attachment by microsoft flow

Hi @golabem ,

Based on the screenshot that you mentioned, I found that you missed a .pdf extension name within your attachment file. Please assign a proper pdf file name (e.g. Test.pdf) to the attachment file in your email.14.JPG

Please do not miss the .pdf extension name within the attachment file as above.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Send pdf created after submiting form in attachment by microsoft flow

Thank you very much, it works perfectly.

 

I had problem with opening it:

2019-09-04_8-58-51_3.png

But I refreshed and typed again everything and problem is gone. THANK YOU!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,764)