cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ruslank
Frequent Visitor

Add Image in Media Library to a Collection

I have a Sharepoint list with a Choice column "FF_Test" that has 4 values in it (Value1, Value2, Value3, Value4)

In PowerApps Media Library i have four images (Value1, Value2, Value3, Value4)

I am trying to create a form where the values from the Choice Column appear with the corresponding images

 

I have tried to create OnStart a collection using:

ClearCollect(colTest, AddColumns(Choices(Test.FF_Test), "Selected", false, "Image", Value));

 

...and display it in the gallery using ThisItem.Value or Text(ThisItem.Value) for the Image but it is still blank and doesn't display anything.

 

Any help or direction is greatly appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@ruslank 

I think the difficult part of what you are trying to do is match up those Choices from a Sharepoint column to an Image.  From what I can see using the Choices() function will make it difficult to do that.  Here's how I got around that problem by manually defining the Choices and their related Images.

 

Step 1:  Load your images into the media gallery.

 

img1.png

 

Step 2:  Add the following code to the OnStart property of your app

 

ClearCollect(
	OptionsCollection,
	{Value:"Value1", Image: Image1},
	{Value:"Value2", Image: Image2},
	{Value:"Value3", Image: Image3},
	{Value:"Value4", Image: Image4}
)

Step 3:  Create a new gallery.  Add an Image with the Image property ThisItem.Image.  Add a Label with the Text property ThisItem.Value.

 

img2.PNG

 

The key here is to make sure Value1, Value2, Value3, Value4 match your Choices in Sharepoint.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

4 REPLIES 4
mdevaney
Super User
Super User

@ruslank 

I think the difficult part of what you are trying to do is match up those Choices from a Sharepoint column to an Image.  From what I can see using the Choices() function will make it difficult to do that.  Here's how I got around that problem by manually defining the Choices and their related Images.

 

Step 1:  Load your images into the media gallery.

 

img1.png

 

Step 2:  Add the following code to the OnStart property of your app

 

ClearCollect(
	OptionsCollection,
	{Value:"Value1", Image: Image1},
	{Value:"Value2", Image: Image2},
	{Value:"Value3", Image: Image3},
	{Value:"Value4", Image: Image4}
)

Step 3:  Create a new gallery.  Add an Image with the Image property ThisItem.Image.  Add a Label with the Text property ThisItem.Value.

 

img2.PNG

 

The key here is to make sure Value1, Value2, Value3, Value4 match your Choices in Sharepoint.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

thank you, @mdevaney  Not exactly what i was looking for. My goal was to avoid having to manage the data in both places: Sharepoint and PowerApps. 

 

With your solution if my values were to change, i have to update them in both places. Any solution to avoid that?

@ruslank 

A Choices column does not give you any option to assoicate an image so I think it is not possible to do only in Sharepoint.

 

Instead, my suggestion would be to change your Sharepoint column to single-line text and then control what choices the user has only from the app.  You could do this easily with the collection I provided in Step #2.  It might not be your ideal solution, but I do not see any other way to achieve control from only one program.

 

---

Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

@mdevaney Just a quick note to say thanks -- this was really helpful for me as I was preparing for an upcoming presentation!  

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,029)