Re: Create folder by sender and date
Hi @datalearner,
You could use an expression to extract what path you need to check. That expression uses a split and first to retrieve the name from the from field. It also uses formatdatetime and concat functions to retrieve the date related folders from the receivedDateTime field. After that you can check if the folder exists and only create it if needed.
Below is an example
I have used the has failed approach, which it will because it will return a NotFound error when the folder does not exist. However, other errors could also occur. So, it is better to use a condition action and check for the NotFound error instead. This is just a simple example to demonstrate the approach.
1. A Get Folder metadata using path is used.
The expression used to reconstruct the path via a concat function.
NameOfLibrary/@{concat(first(split(triggerOutputs()?['body/from'], '@')), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'yyyy'), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'MM'))}
2. A Create new folder action is added
The configure run after setting in this action is configured to only run this action when the previous action has Failed.
Expression used in Folder Path
concat(first(split(triggerOutputs()?['body/from'], '@')), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'yyyy'), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'MM'))
