Flow idea #6: Publish to SharePoint (Simple)

Overview

ProjectWise projects need to publish information to enterprise repositories when design is complete or has reached a certain milestone. Usually the deliverables are PDFs, iModels or other formats that can be consumed outside of a design environment.

We hear form our users that SharePoint is quite often used as enterprise document management system and they need to publish there. In this example we have chosen to demonstrate how to publish document from ProjectWise to SharePoint using Flow. SharePoint has a good Flow connector so there are many ways how this flow could be improved to handle more sophisticated scenarios.

ProjectWise Configuration

For this example, we are using ProjectWise sample datasource that comes with ProjectWise installation.

The ProjectWise configuration for this flow is very simple. There is a saved search that returns documents that need to be published. In this case it is: PDF documents that are in environment ‘Complex’ and that have attribute SharePointUrl empty. The latter attribute was added to the environment.


The flow will store SharePoint URL in the attribute and this will remove the document from search results next time.

The Flow

It is a recurring flow that:

  • Finds documents using saved search
  • Saves document file to a SharePoint folder
  • Sends email notification with a report

Getting list of documents to publish

The first part of the flow is a recurrence trigger, saved search and initializing of variables for result messages.

Publishing a file to SharePoint

Publishing part is an “Apply to each” loop that will be automatically added by Flow editor:

The very first step is to “Get document file” by using Document GUID for a document from search results.

The Compose action is used to create a file name in SharePoint that is a combination of file name in ProjectWise and document version. Expression used in Compose action:

replace(items('Apply_to_each')?['file']?['name'], '.', concat('-', items('Apply_to_each')?['version'],'.'))

Next Create file uses outputs from previous actions to create a file in SharePoint.

Handling errors and recording results

Publishing of a document can fail for several reasons: file may be, or downloading may be interrupted because of slow network, or other reasons. Normally when an action fails flow stops and is marked as failed. In this case we want flow to continue processing remaining documents even when something fails in publishing scope. This flow uses error handling technique that allows to do that.

The ‘Publish a document’ scope (it is important to put all actions that we want to protect with error handling into one scope) is followed by Process Failed Upload and Process Successful Upload scopes. Notice that they are connected by red dotted arrows. Such arrow indicates that there is a special “Run after” condition. To access this setting got to three dot menu on the right side of scope header and select ‘Configure run after’.

Picture below shows run after setting for both scopes. The ‘Process Failed Upload’ scope will execute if publishing will not succeed for one of the possible reasons. Notice that ‘Process Successful Upload’ will execute only if failure handling scope was skipped, i.e. when there was no error.

Inside of Process Failed Upload we simply save a message to Failure Messages array:

Process Successful Upload will generate a sharing link, save that link to attribute of a document in ProjectWise and record success message. Note that ‘Modify a document’ action image was shortened to hide attributes that are not relevant for this example:

 

Sending a report

The last step in this flow is sending an email with results:

The expressions used in message body are:

  • length(variables('Success Messages'))
  • join(variables('Success Messages'), '<br>')
  • length(variables('Failure Messages'))
  • join(variables('Failure Messages'), '<br>')

The flow is ready!

Final Remarks

File size limitation

Microsoft Flow currently has a limitation of 100 MB for internal messages. It means that in some situations file size may be limited by this message size. In practice files up to 90 MB can be transferred without errors.

To overcome this limitation some of the connectors implement a protocol that handles file size in chunks, thus extending maximum file size up to 2 GB. For this protocol to work both receiving and sending end need to support it.

As of time when this article was published SharePoint connector had this limitation. Microsoft informed that they have plans to implement chunk transfer in near future.

ProjectWise Flow connector ‘Get document file’ action implements chunk transfer.

‘Create a new document’ and ‘Modify document’ actions have a limitation of 100MB. In near future Bentley will publish an action ‘Upload document file’ that will support large files.

Ideas to enhance this flow

Here are some, but certainly not all, ideas how this flow could be improved, if needed:

  • The flow could request manager approval before publishing using Flow Approvals feature.
  • ProjectWise document attributes could be saved in SharePoint. Their values can be manipulated.
  • SharePoint action ‘Create file’ will overwrite file if it already exists. The flow could be improved to prevent overwrite and report it as error.
  • List of recipients of publishing report could be read from ProjectWise document attributes to make it better configurable.
  • This flow publishes PDFs. It could find original drawing file that was used to produce this PDF and record publishing status there too.

Resources

 Full expanded flow image can be downloaded here

Parents Comment Children
No Data