First of all, I know that an attachment control is not designed to be used outside of a form. Nevertheless, the Internet shows several examples of this, and my current solution approach is already quite advanced.
Before I describe my problem, here’s a brief explanation: Using a Dataverse table and a gallery, I created a dynamically adjustable form. The table defines the data fields along with their data types, which are then displayed in a gallery. Depending on the data field type, either a TextInput or an attachment control becomes visible within the gallery item. By pressing a button, the gallery is iterated over and, based on the type, either text is written into a column called “Daten” or, in the case of an attachment, into a column called “Daten Anhang”. The dynamic creation of the form and the data saving work flawlessly up to this point. I was also able to verify this with a model-driven app, where I can download the attachment that was uploaded via the canvas app without any issues.
Now to my problem:
In the canvas app, the uploaded attachment is correctly displayed in the attachment control; however, when I try to download it, my browser (MS Edge) gives me the error message that no file could be downloaded. Below are some images and code snippets for clarification.
// shorted function to patch attachment
Patch(
'_REF Vorgang Prozess Datenfelder';
LookUp(
'_REF Vorgang Prozess Datenfelder';
'Vorgang Prozess Datenfeld ID' = recVorgangProzessDatenfeld.'Vorgang Prozess Datenfeld ID'
);
If(
IsBlank(First(recVorgangProzessDatenfeld.AnhangVorgangProzessDatenfeld.Attachments).Value);
{'Daten Anhang': Blank()};
{
'Daten Anhang': {
FileName: First(recVorgangProzessDatenfeld.AnhangVorgangProzessDatenfeld.Attachments).Name;
Value: First(recVorgangProzessDatenfeld.AnhangVorgangProzessDatenfeld.Attachments).Value
}
}
)
)
// Funtion to display attachment in attachmentcontrol
If(
IsBlank(ThisItem.'Daten Anhang'.Value);
Blank();
First(
Table(
{
FileName: ThisItem.'Daten Anhang'.FileName;
Value: ThisItem.'Daten Anhang'.Value
}
)
)
)
// Also not work
//ThisItem.'Daten Anhang'
Structure of the Gallery
File can be found in model-driven app
Download from the Canvas app (bottom) failed, download from the model-driven app (top) succeeded.