Press "Enter" to skip to content

Embedded Canvas Apps for SharePoint Documents

Starting to see a few requirements coming up from clients around surfacing documents in sub grids or being able to access documents through Embedded Canvas Apps for SharePoint from Dynamics 365 CE records.

Thought I would try implementing this through the use of Flow and specifically the OOTB SharePoint connectors. The connector I’m going to be using is the “Send HTTP Request to SharePoint” which allows to construct a custom request.

Essentially the process will involve the normal OOTB SharePoint integration with Dynamics 365 and will have the following steps:

  • Get GUID of current record through the form integration data
  • Query for the relative URL stored on the document location record related to the primary record (using Dynamics 365 connector, as at time CDS didn’t have document locations)
  • Construct an HTTP request to SharePoint to retrieve the list of documents
  • Return the Array of documents to the PowerApp

I’m using an Embedded Canvas App which is on a Dynamics 365 form. This will take the GUID of the record and pass this to the Flow to retrieve the SharePoint Documents. Below is the completed Canvas App on the form.

Let’s Begin

I’m going to start with the call from PowerApps to Flow and then look at how to get the list of documents from SharePoint.

From the PowerApp I have setup a timer to end after a time interval. This call the Flow in question and pass the GUID. I’m using the form integration data to get the contact GUID and passing that to Flow.

The GUID being passed is used to query back into Dynamics to retrieve the SharePoint URL. This is done using a PowerApp parameter to pass to the GUID to the filter query of the Dynamics 365 Connector.

The above query will return a list of records so I filter out to get only the first. I use the relative URL to build the API call to SharePoint. If you do a google search you can learn more regarding the SharePoint API. Essentially I’m calling a GET to the GetFolderByServerRelativeURL function to return back an array of files in the folder.

This is where it gets a little interesting as you can see below I hard code the contact folder and pass the relative URL retrieved from the document location query using body(‘Get_Loc’)[‘value’][0]?[‘relativeurl’] as parameters. Going forward this would need to be configurable to each entity type.

The API call will return an array of documents to be passed back to the PowerApp using a Response action. Worth performing a test so a sample can be used to generate a schema.

Back in the PowerApp designer it is simply a matter of binding the Gallery to the collection retrieved back from Flow. I have hard coded the SharePoint URL so think about providing a configuration for this.

The Edit button is to implement a way to edit document meta data which I will blog about soon.

Implementing all the above the Embedded Canvas App can now pull in the SharePoint documents onto the form.

Check out an old post on Embedded Canvas Apps: https://the365hero.com/blog/2018/12/24/embedded-canvas-apps-for-dynamics-365/

  1. uday v

    Hello 365hero,

    Were you able to retrieve the lookup value from the contact in the embedded canvas app?
    Like the GUID of the parentcustomerid of the contact?

    Thanks
    Uday

    • The 365 Hero

      Hi Mate,

      From what I can see you might need to do a Lookup formula to the account and contact entities with the guid from the Customer lookup.

      Try this:

      If(ThisItem.’Customer Type’ = “accounts”, LookUp(Accounts, accountid = GUID(ThisItem.Customer), ‘Account’), LookUp(Contacts, contactid = GUID(ThisItem.Customer), ‘Contact’))

      Cheers,

      Josh

  2. Jason

    Noticed the (+) symbol at the top of your app and wondered if you have been able to implement adding documents using the (+) through your canvas app?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.