Welcome to our blog where will be sharing tip, tricks and detailed walk-throughs covering all areas of Dynamics 365 but primarily focused on the Field Service and Project Service Apps, Scheduling and integration using Microsoft Flow and the Common Data Service (CDS). We hope you find the blog posts useful and please feel free to comment if you would like us to elaborate on any particular area. 

  • Iain Dalgleish

Part 1: Flow integration with Dynamics Portals using Request and Response

This is the first in a series of blog posts about how using Microsoft Flow with Dynamics 365. This post is focusing on how you can use the Flow HTTP Request Trigger and the Response Action in conjuncton with other Microsoft Flow connectors to expose information on a Dynamics Portal. There are 2 parts to this particular post. In this first post I will demonstrate how you can display a list of GoTo Webinars to users on the Portal and then in Part 2 I will show you how to then extend to allow portals users to register from the list in the the Portal.


You will need to have an instance of Dynamics 365 Portals configured in your Dynamics 365 instance along with a trial (or full) license for GoToWebinar as it is a Premium Flow connector (to sign up for a7-day trial go to https://www.gotomeeting.com/en-au/webinar/try)


The Microsoft Flow Request trigger is very powerful as it generates a unique URL which you can then post to in order to trigger a flow and process as you would any other Flow. When used in conjunction with the Flow Response action it makes it easy for us to return information retrieved from other Flow connectors to other apps such as Dynamics Portals.

The first step is to build the Flow to return the Webinar data required on the Portal. Sign in to your O365 portal and navigate to Flow. Choose the option to create a Flow from blank.

Search for "Request" in the list of triggers.

You will notice that the unique URL is only generated afer saving. Select "GET" from the advanced options although there's no reason it couldn't be a "POST" request which you will see used in Part 2. The sample payload feature is a very useful way of adding parameters to your request by simply entering an example payload in JSON format. For example, if I wanted to take in a date to retrieve webinars from it would like this although i won't be covering this in this blog. Note, how the URL is not generated when you create the trigger but only after save.

Then add a new action step and search for "Webinar". From the available list, select "List Webinars". You will be prompted to sign in to your GoToWebinar account.

Although we are not finished with this Flow yet, save it and then you should notice that a URL has been generated for you to trigger the Flow (refresh if it doesn't immediately appear).

So, all we need to trigger the Flow now is invoke that URL either directly from a browser or from a tool like PostMan (https://www.getpostman.com/). Once, you have made the request you can view the output of the Flow in Run History. Open up the result of "List Webinars" action and you will see the data returned in the Body. Notice how the start and end times of the webinar are held in a nested JSON array object within the main object "times" .

Although we could just return this directly as part of the Response, it'd be nice to make it so that the Start and End Times were part of the main JSON object returned, as we know in this case that we will never have a recurring webinar where multiple start/end times could be included as part of the result.


This leads nicely onto the use of the Flow "Data Operations" and in this particular case the use of the "Select" Data Operation to transpose the information returned from the "List Webinars" action into a format we want to return. More information on Data Operations can be found here https://docs.microsoft.com/en-us/flow/data-operations and there are a very useful addition to your Flow armoury.


So go back in and edit your Flow. After the "List Webinars" action add a new action step and search for "data operations". Choose "Select" from the available list.

Now, we are going to take the "Body" from the List Webinars action and transpose (map) into the JSON object we wish to return as part of this Flow. The JSON object is going to closely resemble the default returned by "List Webinars" although as previously mentioned, we are going to return the StartTime and EndTime as direct properties of the object rather than nested under the "times" JSON array object. We simply add a series of "Name, Value" pairs but when it comes to the Start Time and End time we need to extract the individual object from the first (and only in this case) element in the "times" JSON array object.

The final step in the Flow is to add the Response action to set the data to return from the Flow. So create a new action step and search for "response". Pick the "Response" action.

We are then going to set the JSON object to return with a name of "webinars" and a value of the output of the "Select" data operation. This is obviously a simplistic example but you could return a very complex JSON object here if required.

If you copy & paste the URL into your browser now, you should see something like the screenshot below (if you have only the one trial webinar setup) or more if there are more webinars available.

So, now we have our Flow setup to return our list of webinars, we need to configure our Portal to retrieve the data by making a request to that URL and display the returned data in an appropriate format.


I'm going to use a very simple Web Template which in my case will leverage the DataTables jQuery library from it's CDN (https://cdn.datatables.net/) to dynamically display the results of the "Get Webinars" flow in a grid on a portal web page.

Go into Dynamics 365 and choose to create a new Web Template.

Template HTML Code:

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/bs-3.3.5/jq-2.1.4,dt-1.10.8/datatables.min.css" /> <script type="text/javascript" src="https://cdn.datatables.net/r/bs-3.3.5/jqc-1.11.3,dt-1.10.8/datatables.min.js"></script> <div class="container"> <table id="webinar-data" class="table table-bordered table-hover"> <tr> <th>Subject</th> <th>Start Time</th> <th>End Time</th> <th>Description</th> </tr> </table> </div> <script type="text/javascript"> $(document).ready(function() { var listWebinarsUrl = '<YourFlowRequestURL>'; $.ajax({ url: listWebinarsUrl, type: 'GET', dataType: 'json', }) .done(function(resp) { $.each(resp.webinars, function(i,webinar){ var newRow = "<tr>" +"<td>"+webinar.Subject+"</td>" +"<td>"+webinar.StartTime+"</td>" +"<td>"+webinar.EndTime+"</td>" + "<td>" + webinar.Description + "</td>" +"</tr>" ; $(newRow).appendTo("#webinar-data");

})}) .fail(function() { alert("error"); }); }); </script>


After you've created the Web Template, you need to create the Page Template and then Web Page that refer to that Web Template


Once this has been done, you should be able to log in and navigate to the webinars list via the URL or menu item if you add one.

Hope you've found this useful and in Part 2 I will show you how to add a "Register" button to the List which will trigger another Flow Request passing in the logged in portal contacts details and registering them to the selected webinar.




507 views0 comments