When you copy the YAML code, you will observe the following in Items property.
Items:
=ForAll(
Filter(
TableName,
ID = var_ID
),
{
DisplayName: ThisRecord.Attachment.FileName,
Value: ThisRecord.Attachment.Value
}
)
Items.Name: =DisplayName
Items.Value: =DisplayName // This is the issue!
Even though you're assigning Value: ThisRecord.Attachment.Value, the file still doesn't download when you click on it. That's because Power Apps, for some reason, defaults Items.Value to DisplayName instead of the actual file Value.
Solution:
Just update the Items.Value property like this:
Items.Value: =Value
Now your attachment control knows where the real file is, and clicking it will work as expected!
Ideally it should look something like this :
Items:
=ForAll(
Filter(
TableName,
ID = var_ID
),
{
DisplayName: ThisRecord.Attachment.FileName,
Value: ThisRecord.Attachment.Value
}
)
Items.Name: =DisplayName
Items.Value: =Value // This is the fix
Hope this helps! It worked for me, and I hope it works for you too.