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.
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.
Ok, so if my pick box is empty (and I thought I did the initialize variable part correctly, what may be going wrong?
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.
hello - I get to the 'append to string variable 2' in the "Yes" portion, and it won't allow me to type "HTML Table" in the name. It is acting like a pickbox, and it won't let me enter anything.
Thank you very much for taking a look. The screenshots here show where things stand in my testing, I've been trying differnt things jsut to get a change to the result, whcih is rare. Oriiginally I used the exact syntax as what is in the article.
Apologies, I should have made that clear, also.
There seems to be an issue with HTML. I cannot pinpoint what is wrong specifically in your case.
I do not recommending using head / body elements as it seems that these are added by Outlook connector around HTML contents provided via the action and are actually duplicates. Maybe this confuses HTML rendering? Also for table you could try using thead/tbody tags as provided in the article example ... Maybe your mail client will like them better.
I am setting this up on one of my datasources and am having trouble with the output of the HTML table in the email. The email is set to use HTML.
The table header and first row are correct; the text is in the correct place and the table border is what it should be..
Here are snips of my Flow as well as the output.I've tried changing the border, inputs, outputs (i.e. removing the link) and nothing has worked.Does anyone have any ideas?