
Announcements
Hi Power Apps team,
The pieces of code below are in french so the use of dot and semicolon are differents than english version
I have a problem with a Gallery and picture in attachement in a SharePoint list.
This code is running well to select Items for my Gallery
Filter(BoroA330;statut=position;snmoteur=SNmoteur)
For each Item in my Gallery, i want to display the last picture in attachment, no problem with this code:
Last(ThisItem.'{Attachments}').Value
But i have 6 differents SharePoint list, so i want to put the name of the lists in a variable like this:
Set(BDD;BoroA330)
Filter(BDD;statut=position;snmoteur=SNmoteur)
With this variable in my Gallery i can use all the fields of my List, it s running well:
ThisItem.element
But the code for the picture make an error. '{Attachments}' is not recognize
Last(ThisItem.'{Attachments}').Value
However in the OnSelect of my gallery i use a ClearCollect:
ClearCollect(colDefaut;ThisItem)
and i can display all the pictures in attachments in another screen in another Gallery using the property of an attachments box in a form named attPhotos :
attPhotos.Attachments
The solution i found is to use a Switch in my gallery to select the differents Lists:
Switch(type;
"PW1500G";
If(RadioChoixElement.Selected.element<>"All";
Filter(BoroA220;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
Filter(BoroA220;statut=position;snmoteur=SNmoteur)
);
"CFM56-5B";
If(RadioChoixElement.Selected.element<>"All";
Filter(BoroA320;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
Filter(BoroA320;statut=position;snmoteur=SNmoteur)
);
"CF6-80E1";
If(RadioChoixElement.Selected.element<>"All";
Filter(BoroA330;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
Filter(BoroA330;statut=position;snmoteur=SNmoteur)
);
This code is running well but it s heavy, ugly and it s a problem if i want to add or delete a List in the future because i have 6 or 7 switchs like this in my code. Maintenance and modification of the program are very complicated by this problem.
I tried many differents things but i can't understand why all fields ar recognized but not attachment.
Thank you for your patience and sorry for my english.
Hi @LeVentriloque ,
I will save you some time here - you cannot refer to data sources dynamically - you would have to hard-code it.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps