cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

Image control referenced by text

Hi,

 

I'm making an app that dynamically loads SPList-contenttypes (Laptop, Desktop, ...). I've also embedded a couple of images to the app that represent each contenttype (combination of PowerApps and Flow with the SharePoint REST API).
Now if I use an image control and statically set it to Laptop, the embedded image/icon is shown, no problem there.
nodescr.png

But now I'd like to be able to dynamically select the correct icon in my app, based on the description of the contenttype (I've matched the description of the contenttypes to the name of the embedded icons).
So if the description of the contenttype is "Laptop", use the "Laptop" embedded icon.

This however doesn't work.

 

You can see the image control in the gallery is not being resolved. The description isn't empty as you can see on the label control right next to it:

descr.png

Any ideas how I could get this to work?

 

I know there are a lot of alternatives, but I'm just curious if there's a clever way to do it like this?

1 REPLY 1
Microsoft
Microsoft

Hi NVBC,

 

I'm not sure about 'clever', but as the Image property is either an image library object or URL reference and I'm assuming the Description is a String, the only way I can see making this work is to create a manual lookup of contenttype string to image object in the image statement itself.

 

i.e. Image property:

Switch(ThisItem.Description, 
        "Laptop", Laptop, 
        "Desktop", Desktop)

 

 

Assuming Laptop and Desktop are pre-loaded images, or replace them with urls to image.

Could be a long list.... 🙂

 

 

Hope this helps,


RT

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (38,149)