Flow idea #3: Send Automatic Notifications about New Documents

Teams often need to know when important events, such as creation of new documents or document state changes, happen in their projects. In this article we will demonstrate how to create flow to do it.

First, we must create a saved search in ProjectWise that returns documents of interest. In this example we will use a saved search that finds recently created documents. This is not a limit. A search can be a complex as the team needs it to be!

Next, we will create a flow that sends email notification about new items from the search. Here is an algorithm:

  • Run the saved search every hour to find documents modified during last 24 hours (or any interval longer than notification period).
  • Notify users about documents that were created since the last run of this flow. To do this, flow will save date and time of the last run in ProjectWise. It will use this time to list only documents created after previous run.

ProjectWise Configuration

We use ProjectWise sample datasource for this example. We added a global saved search to the project. In this example it returns documents created using last 24 hours in Work Area BSI400:

We have added a document ‘Last run time’ Under 99_Automation folder to store timestamp of the last run:

  

The Flow

The complete flow is shown in screenshots below.

Note that for ProjectWise actions to work, the work area connection needs to be associated with ProjectWise Could project.

The flow starts with recurrence trigger.

  

The next two actions are for getting date and time for the last run and the current run:

  • The “Find a document by path or GUID” gets properties of a document used to store time of previous run.
  • The “Compose” step saves current time in time zone of ProjectWise server. The expression is:

 

Notice that in this case time zone of ProjectWise server is already UTC, so there will be no change to time stamp. If, for example, ProjectWise server was in US East Coast then the third parameter would have to be ‘Eastern Standard Time’. For complete list of time zone names see https://msdn.microsoft.com/en-us/library/gg154758.aspx .

 

The next action runs a saved search and finds all new documents. If this flow ran recently, then it may include documents about which it has already sent a notification. We will filter the list in a following step.

To avoid double notification, we use ‘Filter array’ action to select only documents that were created after last run, i.e. all cases when last run timestamp is less than document creation date.

To build this action:

  • Add Body from ‘Find documents by saved search’ action into ‘From’ field
  • In the first field select description field from ‘Find document by path or GUID’ action
  • In the second field choose any operator, e.g. Contains
  • In the third field select Creation time from saved search results
  • Then go to advanced mode and edit expression to have “@less” operation instead.

 

Initialize a variable to store HTML for email body and begin a table. It will be used in the if statement below. The ‘Description’ field is from ‘Find document by path or GUID’ action.

Next, add a condition. The flow will send email only if filtered array is not empty. The expression in the first field is:

The first step in the Yes branch is to add a line for each document.

First add action “Append to string variable”. Flow will automatically add ‘Apply to each’ after referring to any property from the filtered array.  

Note that the properties used in ‘Append to string variable’ must be taken from the filtered array and not from the saved search action.

Lastly add actions to append end of the table and send the email.

In this example the email is sent to a single fixed recipient. This flow could be easily improved to read list of recipients from an excel spreadsheet or configuration document properties. Such improvement would allow to update list of recipients without modifying the flow. We kept a single fixed email address for simplicity.

The “No” branch of condition has no actions.

Now the last step in this flow. Save time of this run that was retrieved in earlier ‘Compose’ action.

The end.

Anonymous