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:
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 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:
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:
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.
In fact, all files are recorded more than once. Even though the timestamp is being changed, it is not working as it should. How can we fix it?
The 'Creation time' time stamp is a bit too complicated now, how can I change it so it comes out simplified like: dd/mm/yyyy hh:mm?
This is the current one:
This is what I would like to have:
If only some files are recorded twice, it may be that either a time stamp is not saved, or there is some confusion with timestamp comparison... it is hard to say anything without seeing the data.
Thank you, Audrius! Besides, I have one more question: Although the last run time is being updated in the "Last run time" file description, my program is identifying the same files several times. Do you know what could be wrong? Here are some prints of the program to assist you.
Barbara, the "Last run time" document initially must be created manually with a valid last runtime timestamp in the description - this will be updated later, when the Flow runs.
Hi! I have some doubts about the "Last Run Time" file. How can I create it and what do I need to do for it saves the current time in time zone of ProjectWise server?
Back at testing this example, and I get stuck at this point -
Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The action(s) 'filter_array' referenced by 'inputs' in action 'Condition' are not defined in the template.'.'.
I am beginning in Power Automate. To try I have built the Flow idea #3 but I get an error on the “Find documents by saved search” step. Detail on error said: “The response is not in a JSON format”. Any idea where it comes from to help me go further. thank you
Ben, user names in document properties are supported only since ProjectWise DI Update 3.2... When used with earlier versions of DI server these properties are not returned by the connector.
Thanks I have checked and I can see this field is not listed in the metadata it pulls out from the system but it does appear as one the default options that comes out from the saved search results.
It is hard to day without seeing your Flow. You can always examine past Flow runs and see inputs and outputs of each step. Maybe this will help to find where the value gets lost?
This is awesome and fills a need a lot of users I work with have been asking for. But on a couple of scripts I have setup we have the Created By column appended to html string, but it is always blank even though I have passed the data through from search. Any ideas why this might be?
Did you choose variable type to be 'string' in the initialize block? I think 'Append string variable' shows only string variables.
Audrius -
Ok, so if my pick box is empty (and I thought I did the initialize variable part correctly, what may be going wrong?
Kirk,
it is a pickbox. It lists all variables defined in this flow. There is a previous step called "Initialize variable" where the "HTML Table" variable is defined.