Product Drawing PowerApp. Part 1.

Product Drawing PowerApp. Part 1.

Let’s say that we have a requirement to view Product drawings from the production order form, so the person who works on the job can easily access all engineering documentation if required. All product drawings are stored on a SharePoint portal and we just need to find and display a file to the user.

In this scenario the structure of the Document library on the SharePoint is very simple. We have a site with Document library where we store all product drawings as pdf files. Also, we assume that file name and Title always starts from the Item number that is used in MSDyn365FO, see below:

ProductDrawingApp_SharepointLibrary

In this blog post we will build a PowerApp that performs following actions:

  1. When the app is opened from MSDyn365FO we pass to it Item number value from the selected production order.
  2. On the app start we trigger MS Flow to get files from SharePoint portal with Title that starts from the Item number passed on the step 1.
  3. We trigger MS Flow to display in the app pdf file content returned on the step 2.

Looks like that is all, let’s go and try to build this app!

MS Flow 1: Get files from SharePoint

Here is a flow that we need to configure to get required file information from the SharePoint:

ProductDrawingApp_FlowGetFiles

Step 1. PowerApps: On the first step we use PowerApp trigger to call our Flow from the PowerApp. There are no additional parameters.

Step 2. Get files (properties only): We use “Get files (properties only)” to extract a list of files and its properties from the SharePoint. The Flow accepts Site address and Library name as parameters. In addition, we apply filter by Title field to get only files with name that starts from specific value passed from the power app:

startswith(Title, '@{triggerBody()['Getfiles(propertiesonly)_FilterQuery']}')

Step 3. Select: We use select action to get File name and Title values for each file to pass it to the PowerApp. We set From parameter with the “Value” that is a result from the previous step. Then, we map Title, File name with file properties received:

ProductDrawingApp_FlowGetFiles_Select

Step 4. Response: On the last step in the Response we pass to the Body parameter result of the Select action (“Output”), in addition we use below sample to generate Response body JSON schema:

[
    {
        "Title": "D0003",
        "FileName": "D0003.pdf"
    }
]

ProductDrawingApp_FlowGetFiles_Response

MS Flow 2 – Display Pdf content in power app

Due to the authentication restrictions we cannot display pdf file content directly from the PowerApp, therefore we require a Flow that does it for us. To achieve that I have used Floxy method, and my Flow looks as follows:

ProductDrawingApp_FlowGetFiles_FlowPdfView

We have finished with MS Flow part and in the next blog post we will create a PowerApp. Stay tuned.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s