{"id":1997,"date":"2016-10-14T11:08:33","date_gmt":"2016-10-14T10:08:33","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=1997"},"modified":"2016-10-14T11:08:34","modified_gmt":"2016-10-14T10:08:34","slug":"o365-using-sharepoint-boolean-fields-with-microsoft-flow","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/","title":{"rendered":"[O365] Using SharePoint boolean fields with Microsoft Flow"},"content":{"rendered":"<p>My <a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-changing-the-language-of-microsoft-flow\/\">previous post<\/a> just now was on the topic of Microsoft Flow, the workflow-style application that allows you to perform &#8220;if this, than that&#8221; type logic linking different applications together. Basically, Flow provides you a way of automating actions by having a set of triggers, some logic and using API&#8217;s to perform actions. It wraps all of this in a nice and easy to use user interface, making this functionality that pretty much everyone can leverage. Power to the business!<\/p>\n<p>In this post I want to show how I created a real-life flow to automate a\u00a0process for expense declarations. The process is a really simple one:<\/p>\n<ul>\n<li>We&#8217;ve created an Expense Declarations library on SharePoint.<\/li>\n<li>We added a new Expense Declaration content type which has an Excel template for the declaration.<\/li>\n<li>We also added\u00a0a boolean field &#8220;Ready&#8221; which signals the expense form is ready for processing.<\/li>\n<li>The form should now be sent to the person handling the declarations. Of course it would be even better to send it directly into an API, but unfortunately that&#8217;s not available for us.<\/li>\n<\/ul>\n<p>As said, the basic elements of a flow are a trigger, some logic (conditions) and actions. Let&#8217;s go!<\/p>\n<p>&nbsp;<\/p>\n<h2>Defining the trigger<\/h2>\n<p>To create the flow, we head over to <a href=\"http:\/\/flow.microsoft.com\">flow.microsoft.com<\/a>\u00a0and after signing in (or up), we begin with a blank flow. The first action we add is &#8220;When an existing item is modified&#8221;. This is because:<\/p>\n<ol>\n<li>The &#8220;<strong>created<\/strong>&#8221; action will fire off immediately after the form\u00a0was created and is probably still empty.<\/li>\n<li>The action for a <strong>modified document<\/strong> will not contain the correct information, our Ready field will not be present. This is supposed to be changed in the future though.<\/li>\n<\/ol>\n<p>So we set up the existing item modified trigger:<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/flow_itemmodified\/\" rel=\"attachment wp-att-1998\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1998\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_itemmodified.png\" alt=\"flow_itemmodified\" width=\"481\" height=\"540\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_itemmodified.png 481w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_itemmodified-267x300.png 267w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/a><\/p>\n<p><strong>Note:<\/strong> because your library is a library, it might not show up in the suggestions. That doesn&#8217;t mean you cannot use it though, just type in the name and you should be good to go.<\/p>\n<p>&nbsp;<\/p>\n<h2>Creating a condition<\/h2>\n<p>Next, we need to set-up the condition. We want the declaration to be sent only when the Ready field is set to Y<strong>es<\/strong>. Because the value is stored as a boolean, the field value sent to flow will be &#8220;true&#8221;. You can check that by running your flow (trigger it from SharePoint after saving) and clicking the trigger to inspect the values coming in:<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/flow_trigger\/\" rel=\"attachment wp-att-2001\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2001\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger.png\" alt=\"flow_trigger\" width=\"494\" height=\"203\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger.png 494w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger-300x123.png 300w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/a><\/p>\n<p>Check out the value for Ready:<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/flow_trigger2\/\" rel=\"attachment wp-att-2002\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2002\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger2.png\" alt=\"flow_trigger2\" width=\"499\" height=\"61\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger2.png 499w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_trigger2-300x37.png 300w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/a><\/p>\n<p>So now the most straightforward thing to do would be to set up the condition like this:<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/flow_condition\/\" rel=\"attachment wp-att-1999\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1999\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition.png\" alt=\"flow_condition\" width=\"611\" height=\"172\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition.png 611w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition-300x84.png 300w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/a><\/p>\n<p>But this does not work. I suspect the engine will handle\u00a0&#8220;true&#8221; as a string which would give a comparison of &#8220;true == &#8216;true'&#8221; which is false. To fix\u00a0this, put the editor in advanced mode and use the following expression:\u00a0@equals(triggerBody()?[&#8216;Ready&#8217;], bool(1)).<\/p>\n<p><a href=\"http:\/\/blog.repsaj.nl\/index.php\/2016\/10\/o365-using-sharepoint-boolean-fields-with-microsoft-flow\/flow_condition2\/\" rel=\"attachment wp-att-2000\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2000\" src=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition2.png\" alt=\"flow_condition2\" width=\"609\" height=\"168\" srcset=\"http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition2.png 609w, http:\/\/blog.repsaj.nl\/wp-content\/uploads\/2016\/10\/flow_condition2-300x83.png 300w\" sizes=\"(max-width: 609px) 100vw, 609px\" \/><\/a><\/p>\n<p>bool(1) will convert to &#8216;true&#8217; so our comparison should\u00a0now be &#8220;true == true&#8221; whenever the Ready field is set to Yes in SharePoint.<\/p>\n<p>&nbsp;<\/p>\n<h2>Setting up the action<\/h2>\n<p>Lastly, I created a simple e-mail action to send out a notification to the correct user. Ideally I wanted to add the file contents to that e-mail but that isn&#8217;t possible (yet) due to the &#8220;item modified&#8221; trigger which is not aware of a file. I tried several ways to get around this but didn&#8217;t succeed. You can probably get there with something customized like an Azure Function, but for now the plain old e-mail will do. Simply set-up an Office365 e-mail action to send out a mail to inform the correct user a new declaration has been added, paste in the link to the library and you&#8217;re set.<\/p>\n<p>&nbsp;<\/p>\n<p>When I find a way to attach the file to the e-mail or send a direct link to the file, I&#8217;ll update this post!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My previous post just now was on the topic of Microsoft Flow, the workflow-style application that allows you to perform &#8220;if this, than that&#8221; type logic linking different applications together. Basically, Flow provides you a way of automating actions by having a set of triggers, some logic and using API&#8217;s to perform actions. It wraps<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[176,60,39],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-wd","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/1997"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=1997"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/1997\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=1997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=1997"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=1997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}