Forum Discussion
SharePoint Workflow or Microsoft Flow?
- Aug 23, 2017
Hello Oz,
This is a great scenario for Microsoft Flow. I'll walk you through how I built a flow that does essentially what you described below. It's a bit long, but it should cover every single bullet point that you outline.
First, there's a SharePoint document library that you'll upload drafts to. This flow will trigger based on the draft being uploaded to that document library. You can use the When a file is created (properties only) trigger.
I assume that you don't want to immediately start the approval process when you upload the draft. Instead, I've added a next step that lets you decide when the draft is ready to be sent to the official approver(s). We also can use this step to collect the email address of the consultant that the contract will be sent to (you could also use a custom column in the document library to enter that information - but for the purposes here it's easier to enter it once you kick off the approval section).
Now that the approval process is going to start, you'll need to add a Do until loop. This loop will continue until both the approver(s), and the consultant themselves, have approved the document. That will start out looking like this, once you add the approval step in:
For the first approval step inside the do until, you'll want to send a link to the final draft of the contract to the approvers. You can provide any number of approvers on the Assigned To line. You will also want to include a friendly message to the approvers indicating what they are approving. Filled out, that will look like this:
Now, there are two possibilities - either the approvers liked the contract draft and you can send it off to the vendor, or, they requested revisions and you want to be notified of those comments. To handle these two possibilities, you'll need a condition:
Inside the top condition box, on the left hand side you'll use the Add dynamic content option to pass in the Response from the approver. Let's look at each side of the condition one-at-a-time.
Starting with the If no side - we will send you an email requesting your revision. That email will also contain a button that you can click once you are done with the revisions to the contract so you can inform the Flow to restart the approval loop.
This email, when it gets sent, will look something like this:
Now, let's look at the If yes side. First, we are going to get the latest word document content so we can send an attachment to the contractor. Ideally, you could get a link but since the contractors may not be in your Office 365 tenant, an attachment is likely the easiest way to accomplish this. Next, send an email to the contractor with the document attached:
This email, when its sent, will look something like this:Now, you'll need a second condition to check if the contractor is happy with the contract or not.
If they select Revision needed then you'll need to send a similar mail as above to yourself to update the contract. Thus, in the If yes side you'll add this step:
The flow will now wait for you to edit the word document, and then select the Revisions completed button in your email. When you select that button the approval process will loop to the top again and restart with the latest version of the document. You won't need anything in the If no side because no further revisions are required if the contractor approves.
You may have noticed that I skipped over the condition of the Do-until. This is because you need to add the actions inside first, before you can reference them in the Do-until condition. The condition will have two parts, because you want both your approver, and the contractor to approve. To build such a compound condition today you'll use the Edit in advanced mode button. In advanced mode you can use Microsoft Flow's excel-like syntax to build powerful boolean statements. In this case, that expression will look like:
@and(equals(body('Start_an_approval')?['response'], 'Approve'),equals(body('Send_approval_email_to_vendor')?['SelectedOption'], 'Approve'))
The exact values inside the quotes of the body() functions may vary depending on the names of the actions you give in your flow.
Now that you have completed the approval loop, the next step is to generate a PDF of the finalized contract and send it to the contractor for signature. First, download the finalized content of the word document:
In Microsoft Flow, we have a partner, Muhimbi, who provides functionality to generate PDFs from Word documents. If you haven't used Muhimbi before you can sign up for a free trial. That action is very simple, it takes the Word document content from the above step and the file name:
We will use the generated PDF to send the contract to the contractor for signature. Notice I have included the file name in the subject line, that's important for the next step. You can also provide additional instructions, for example:
Next, you will have the flow wait for the contractor to respond to the above email with an attachment. The reason that you must include the file name in the subject is because flow will specifically wait for the contractor to respond to that thread - if they happen to send you another email with an attachment in the meanwhile you don't want that being uploaded to your SharePoint. So, add on the When a new email arrives step and fill it out like below:Notice the use of the file name in the Subject filter, as well as the fact that you're looking for emails that have attachments, and that you want to Include Attachments in the step.
The final step of the flow is to upload this attachment to your document library. Be sure to add (signed).pdf to the name of the file.
The most complicated part of this is email attachments can normally be a list of items -- but in this case you just want the first email attachment. You can use another flow expression to get this attachment by itself. That's what the pink value is above in the File content field. The full expression would look like this:
base64ToBinary(first(first(body('Wait_for_vendor_response')['value'])['Attachments'])['ContentBytes'])
Now you're almost done. However, there is one more change that needs to happen. Because the above attachment is being uploaded to the same document library you're monitoring -- this whole process will also be triggered on the signed PDFs being uploaded. This isn't what you want, so you should go back to the top of the flow, and add one more condition:
In the condition, we check to see if the Name ends with (signed). If it does then we immediately terminate the flow. This will prevent you from getting double approval flows. You could also accomplish something similar by having a separate document library for your signed PDF's. In the end the full flow looks like this:
I hope that this was useful for you to see how this could be done in Microsoft Flow. If you don't mind, I would like to blog about this scenario on the flow blog because I think it's a very interesting one (let me know if that's okay!). I can also make a template out of this flow if you're okay with it being public -- then you can just use that template and you won't have to configure it all yourself based on these instructions :)
Let me know what feedback you have, and I would love to hear if you find this meets your needs or not.
Thank you,
-Stephen
Hello Oz,
This is a great scenario for Microsoft Flow. I'll walk you through how I built a flow that does essentially what you described below. It's a bit long, but it should cover every single bullet point that you outline.
First, there's a SharePoint document library that you'll upload drafts to. This flow will trigger based on the draft being uploaded to that document library. You can use the When a file is created (properties only) trigger.
I assume that you don't want to immediately start the approval process when you upload the draft. Instead, I've added a next step that lets you decide when the draft is ready to be sent to the official approver(s). We also can use this step to collect the email address of the consultant that the contract will be sent to (you could also use a custom column in the document library to enter that information - but for the purposes here it's easier to enter it once you kick off the approval section).
Now that the approval process is going to start, you'll need to add a Do until loop. This loop will continue until both the approver(s), and the consultant themselves, have approved the document. That will start out looking like this, once you add the approval step in:
For the first approval step inside the do until, you'll want to send a link to the final draft of the contract to the approvers. You can provide any number of approvers on the Assigned To line. You will also want to include a friendly message to the approvers indicating what they are approving. Filled out, that will look like this:
Now, there are two possibilities - either the approvers liked the contract draft and you can send it off to the vendor, or, they requested revisions and you want to be notified of those comments. To handle these two possibilities, you'll need a condition:
Inside the top condition box, on the left hand side you'll use the Add dynamic content option to pass in the Response from the approver. Let's look at each side of the condition one-at-a-time.
Starting with the If no side - we will send you an email requesting your revision. That email will also contain a button that you can click once you are done with the revisions to the contract so you can inform the Flow to restart the approval loop.
This email, when it gets sent, will look something like this:
Now, let's look at the If yes side. First, we are going to get the latest word document content so we can send an attachment to the contractor. Ideally, you could get a link but since the contractors may not be in your Office 365 tenant, an attachment is likely the easiest way to accomplish this. Next, send an email to the contractor with the document attached:
This email, when its sent, will look something like this:Now, you'll need a second condition to check if the contractor is happy with the contract or not.
If they select Revision needed then you'll need to send a similar mail as above to yourself to update the contract. Thus, in the If yes side you'll add this step:
The flow will now wait for you to edit the word document, and then select the Revisions completed button in your email. When you select that button the approval process will loop to the top again and restart with the latest version of the document. You won't need anything in the If no side because no further revisions are required if the contractor approves.
You may have noticed that I skipped over the condition of the Do-until. This is because you need to add the actions inside first, before you can reference them in the Do-until condition. The condition will have two parts, because you want both your approver, and the contractor to approve. To build such a compound condition today you'll use the Edit in advanced mode button. In advanced mode you can use Microsoft Flow's excel-like syntax to build powerful boolean statements. In this case, that expression will look like:
@and(equals(body('Start_an_approval')?['response'], 'Approve'),equals(body('Send_approval_email_to_vendor')?['SelectedOption'], 'Approve'))
The exact values inside the quotes of the body() functions may vary depending on the names of the actions you give in your flow.
Now that you have completed the approval loop, the next step is to generate a PDF of the finalized contract and send it to the contractor for signature. First, download the finalized content of the word document:
In Microsoft Flow, we have a partner, Muhimbi, who provides functionality to generate PDFs from Word documents. If you haven't used Muhimbi before you can sign up for a free trial. That action is very simple, it takes the Word document content from the above step and the file name:
We will use the generated PDF to send the contract to the contractor for signature. Notice I have included the file name in the subject line, that's important for the next step. You can also provide additional instructions, for example:
Next, you will have the flow wait for the contractor to respond to the above email with an attachment. The reason that you must include the file name in the subject is because flow will specifically wait for the contractor to respond to that thread - if they happen to send you another email with an attachment in the meanwhile you don't want that being uploaded to your SharePoint. So, add on the When a new email arrives step and fill it out like below:Notice the use of the file name in the Subject filter, as well as the fact that you're looking for emails that have attachments, and that you want to Include Attachments in the step.
The final step of the flow is to upload this attachment to your document library. Be sure to add (signed).pdf to the name of the file.
The most complicated part of this is email attachments can normally be a list of items -- but in this case you just want the first email attachment. You can use another flow expression to get this attachment by itself. That's what the pink value is above in the File content field. The full expression would look like this:
base64ToBinary(first(first(body('Wait_for_vendor_response')['value'])['Attachments'])['ContentBytes'])
Now you're almost done. However, there is one more change that needs to happen. Because the above attachment is being uploaded to the same document library you're monitoring -- this whole process will also be triggered on the signed PDFs being uploaded. This isn't what you want, so you should go back to the top of the flow, and add one more condition:
In the condition, we check to see if the Name ends with (signed). If it does then we immediately terminate the flow. This will prevent you from getting double approval flows. You could also accomplish something similar by having a separate document library for your signed PDF's. In the end the full flow looks like this:
I hope that this was useful for you to see how this could be done in Microsoft Flow. If you don't mind, I would like to blog about this scenario on the flow blog because I think it's a very interesting one (let me know if that's okay!). I can also make a template out of this flow if you're okay with it being public -- then you can just use that template and you won't have to configure it all yourself based on these instructions :)
Let me know what feedback you have, and I would love to hear if you find this meets your needs or not.
Thank you,
-Stephen
- Oz OscroftAug 23, 2017Iron Contributor
Stephen, I bow down before you! Thank you so much for taking the time to look at this in such detail and I'd be more than happy for you to blog about it and create a public template. This scenario (draft, share for review, get approval, finalise) must be so common across organisations that I'd be amazed if the template weren't well used.
Thanks again and I look forward to seeing the finished product and trying it out with our contractors.
- Stephen SicilianoAug 26, 2017Microsoft
Hi, I have published the template here: https://flow.microsoft.com/galleries/public/templates/ce9b6e9b147a49f58e5215e335285cd7 - hopefully you find it useful!
- Jason GaylerJan 08, 2018Microsoft
super helpful!
- Vivek JainFeb 22, 2018Iron Contributor
In dilemma deciding between Workflow vs Flow. For the simple requirements I vote for native workflows, since the Flow option is, tied to individual user (instead of being part of site/sub-site), there are additional significant cost in future (source https://us.flow.microsoft.com/en-us/pricing/)
The Flow not being part of "Site/Sub-site" will not be part of "Site Template" and hence will be an object stored apart from site/sub-site making it harder to maintain the inventory from Administrator point of view. The emails sent out in Flow option would have "sender" as individual user's email address.
So for regular activities which can be accomplished through "native workflow" I feel we should continue with that. Hopefully, there is no plans from MS to stop supporting the "native workflows" in near/long term future.
- Ole_EinarMar 13, 2019Copper Contributor
The costs will be rather insane for larger organizations (like mine) using Flow over SPD workflows for simple tasks. I my opinion something has to be adjusted how the plans work...
- Perry ArmirasMar 22, 2018Copper Contributor
Hey Stephen Siciliano ,
I've got a question regarding the "Revisions Completed" link in the email sent out in the IF NO branch of the Check if Approved condition. How was this implemented? In what way does it notify flow to restart the approval loop?
Thanks!
- Stephen SicilianoMar 23, 2018Microsoft
Hello, if you want to make it repeat inside of the Flow until it's approved, then you add a "Do until" loop. This loop would check at the end if the request has been approved yet -- if not then it'll restart the loop.
- biaparDec 03, 2018Copper ContributorDo you use Microsoft Form to build the form?
- Stephen SicilianoDec 03, 2018Microsoft
Microsoft Forms is a great and simple way to get started. You can also use Microsoft PowerApps.