cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HiroakiSasaki
Helper I
Helper I

Lookup an item from SharePoint list and show its attachments on attachment control on form as default

Hi, 

 

What I want goes as below.

 

1) Using lookup, get an item from SharePoint list, which may have single or multiple attachments.

2) get the attachment(s) and set it in a variable

3) show it on attachment control on form, using the variable

 

In my scenario, I'm not using Gallery, so I cannot use ThisItem.

Using ThisItem, I know we can get attachment like this: ThisItem.'{Attachments}'

 

But in my case, users will open the form screen directly from a link with parameter ID of the item (the link is distributed via email).

So, I'm looking up an item by the parameter ID, but can't get `{Attachments}'

 

I'm writing like this:  Lookup([SPlist], ID=[ParameterID]).XXX

 

But I do not see the option '{Attachments}' to replace XXX.

 

It seems there is some difference between data lookup gets and data ThisItem holds.

Any ideas?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @HiroakiSasaki ,

Firstly you cannot save an attachment as a Variable. You can display attachments from another list in a gallery with

LookUp(
   OtherList,
   ID = YourIDParameter
).Attachments

and then the name and (if an image file) the image in this gallery.

 

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

 

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @HiroakiSasaki ,

Firstly you cannot save an attachment as a Variable. You can display attachments from another list in a gallery with

LookUp(
   OtherList,
   ID = YourIDParameter
).Attachments

and then the name and (if an image file) the image in this gallery.

 

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

 

Hi, @WarrenBelz !

Thank you for sharing knowledge!

As you wrote, if I designate the gallery control, which has the target SharePoint List as items source, I successfully get the attachment.

LookUp(Gallery.AllItems,ID=Param("ID")).Attachment

 

 But I don't get what you mean by saying you cannot save an attachment as a Variable.

Set(varAttachment,LookUp(GalInquiry.AllItems,ID=Param("ID")).Attachment)

After executing the function above, I got below result. Doesn't it mean I saved the attachments in a table-type variable?

HiroakiSasaki_0-1644480005502.png

 

Hi @HiroakiSasaki ,

Sort of - you did not save the actual file however - only the references to it (you cannot download it as you would from an attachment control)

HiroakiSasaki
Helper I
Helper I

@WarrenBelz 

 

I got it. Thank you for your reply. My issue is now solved!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,738)