web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to replace a Share...
Power Apps
Answered

How to replace a SharePoint List name by a variable in formula

(0) ShareShare
ReportReport
Posted on by 16

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.

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard