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.
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.
It is a recurring flow that:
The first part of the flow is a recurrence trigger, saved search and initializing of variables for result messages.
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.
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:
The last step in this flow is sending an email with results:
The expressions used in message body are:
The flow is ready!
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.
Here are some, but certainly not all, ideas how this flow could be improved, if needed:
Full expanded flow image can be downloaded here.
Sorry for a delayed reply.
Method #1: Flow adds Apply to Each element automatically once an element array is accessed in the action. For this to happen:
Audrius, I was trying to implement the above Flow and appear to be stuck at the Apply To Each. How do I create the Publish Document area within the Apply To Each?