I have two files (xlsx & pdf) in sftp folder. These are the requirements I need to complete:
Edited: This is what I tried first. Used get metadata and If condition activity. get metadata activity
If condition activity expression: If condition activity expression
The two files are existing so I am expecting to receive the notebook in True condition, however, notebook in False condition is running.
I have tried your expression, and I got similar results.
Here, in your expression, you are checking .xlsx
and .pdf
strings existing or not in the array. But these are only substrings of each item in the Child items array. The contains()
for an array only gives true
when the given total string is in the array which is not in your case. To achieve your requirement, try the below approach.
First, in the Get meta data activity, give the path till only your source folder. Don't include the file name. Add Child items property.
As you already know the file name without extension, now use the below expression in the if activity.
@and(contains(string(activity('Get Metadata1').output.childItems),concat('DA_12345','.pdf')), contains(string(activity('Get Metadata1').output.childItems),concat('DA_12345','.xlsx')))
This expression first converts the total child items array into a string and then checks whether both file names are in the string or not. I have given the file names as it is in the expression, you can use your parameters.
Now, it will work as expected.
You can also try exists
option in the Get meta data activity by giving the file name. This option gives true
if the given file name exists in the given folder and false
if not exists.
But you need to use two Get meta data activities for this, in which one is for .pdf
and another is for .xlsx
. After both activities, you can directly use this expression in the if activity.
@and(activity('Get Metadata1').output.exists,activity('Get Metadata2').output.exists)