Resources
Quick tip - Dynamic SharePoint download
To support workers, technical drawings and operating and order data are effectively displayed on screens in manual or semi-automated production environments and in quality management. PDF is often the preferred format for these documents.
The article explains how to use a SharePoint document library to store PDFs, including how to download these files in Peakboard Designer and how to integrate them dynamically into visualizations.
The SharePoint document library
The following screenshot shows a standard document library in a typical Office 365 environment. Within the library, there is a subdirectory called Current that contains all current documents. The old documents are stored in Archive.
Let’s assume the company manufactures three different products called P01 to P03. For each product there is a technical drawing whose PDF file is named accordingly. The x.pdf file contains only a red cross and is used as a placeholder when no useful data is displayed.
Linking the Peakboard project with SharePoint
Right-click on [Resources], select [Add cloud resource] and then [SharePoint] (1).
Authenticate yourself with your Office 365 account in the dialog that has opened. The account requires sufficient permissions to access the desired files in the document library.
The file selection dialog opens. Select the file x.pdf (1) as a placeholder file for the project.
Drag and drop the PDF resource onto the workspace to create a PDF control. Then activate the checkbox [Used in scripting] (1) in the attributes and give the control a name (2).
Setting up the data structure for dynamic loading
A factory worker should be able to dynamically select the files with the various technical drawings from a list of document numbers. To do this, create a list with these numbers. To do this, right-click on [Variables] and select [Add list] (1).
Give the list a name (1) and create a column with the data type [String] (2). Then create a corresponding row for each product (3).
Next, drag a Drop down control onto the workspace. You will find the Drop down control in the [Interactive] area (1). Place this Drop down above the PDF control. To allow the user to select the product number, bind the list variable to the Drop down control in the attributes (2).
Then activate the checkbox [Used in scripting] (1) in the attributes and give the Drop down control a name (2) so it can be used in the next step.
The script for dynamic loading
To enable dynamic selection, create a Selection Changed Event script (1) for the Drop down Control by clicking on the corresponding icon.
With the first three lines, you create the file path of the desired PDF file relative to the root directory of your document library using the value selected in the Drop down list. In this case, for example, /Current/
+ P01
+ .pdf
.
To do this, first create a [Local variable] of data type string under [BASICS].
For the first line, you then add a building block with the directory /Current/ to the Building Block [Set] of this variable.
The second line consists of the Building Block [Append] of the variable in combination with the Building Block [Get value] of the Drop down control under [CONTROLS], [Screen name], [Control name] and [Selected value].
For the third line, use the Building Block [Append] of the variable again and combine it with the file extension .pdf
With the last line, you set the source of the PDF control to the newly created file path. This triggers an update and allows the PDF control to download and display the document from SharePoint.
To do this, drag the Building Block [Set value] of the PDF control from the [CONTROLS], [Screen name], [Control name] and [Source] area below to the existing Building Blocks and combine it with the Building Block [Get] of the local variable created at the beginning.
After you have saved the script, you can start the preview and test your visualization. Each time the value in the Drop down list is changed, the reload process is triggered and the PDF file changes. In this case, we have a fixed list of products. In the real use case, the list of products could be dynamically retrieved from an ERP system such as SAP.