Hello @Pendleton, David
There are a number of possible issues :
- Empty Braces in 'If condition' Activity:
- This suggests that either the output of the
Get Target File Metadata
activity or the value stored in thePreviousModifiedDate
variable might be empty or null. - The
@greater
function then likely fails to compare the dates correctly due to this missing data, leading to unpredictable results.
- This suggests that either the output of the
- 'Random' File Selection:
- Since the comparison within the
If condition
is likely not functioning as intended, the subsequent actions in your Logic App might execute randomly or based on some other unrelated criteria.
- Since the comparison within the
- Date Formatting Mismatch:
- While it's less likely, ensure that both dates are being formatted consistently using
'yyyy-MM-dd HH:mm:ss'
. A mismatch could lead to unexpected comparison results.
- While it's less likely, ensure that both dates are being formatted consistently using
Troubleshooting Steps:
Check for Empty Values:
- Add a
Compose
action before theIf condition
to inspect the output ofGet Target File Metadata
and the value ofPreviousModifiedDate
.- Ensure both contain valid date/time values and are not empty or null.
- If either is empty, investigate why that activity/variable isn't populated correctly.
- Consider adding a `coalesce` function to handle the possibility of null values. For example: ```javascript @greater(coalesce(formatDateTime(activity('Get Target File Metadata').output.lastModified, 'yyyy-MM-dd HH:mm:ss'), '1900-01-01 00:00:00'),
- Ensure both contain valid date/time values and are not empty or null.
coalesce(formatDateTime(variables('PreviousModifiedDate'),'yyyy-MM-dd HH:mm:ss'), '1900-01-01 00:00:00')) ```
- This will replace null dates with a default value, preventing errors in the comparison.
**Verify Date Formatting:**
- Double-check that both dates are consistently formatted using `'yyyy-MM-dd HH:mm:ss'`.
**Enable Run History with Logging:**
- Turn on detailed logging in your Logic App's Run History to track the values of variables and activity outputs throughout the execution. This will help pinpoint where the issue originates.
Example Fix (Assuming Empty lastModified
):
If the lastModified
property is sometimes empty, you might need to add a condition to handle that case specifically:
@if(empty(activity('Get Target File Metadata').output.lastModified), false,
@greater(formatDateTime(activity('Get Target File Metadata').output.lastModified, 'yyyy-MM-dd HH:mm:ss'),
formatDateTime(variables('PreviousModifiedDate'),'yyyy-MM-dd HH:mm:ss')))
Kindly follow the suggestions and let us know the results !
--
I hope this helps!
Kindly mark the answer as Accepted and Upvote in case it helped!
Regards