cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tuuman
Resolver I
Resolver I

Using images from media in gallery view

Hi!

 

We have created an app that shows every contact information of employees or our organization. We have created a gallery view that displays contacts names, phonenumber, address and an image of the person. Originally this image was picked from Office 365 data but we noticed some lag with loading the image when the app was in use. While not completely unusable we started seeking better way to load the images.

 

So what we have done so far is that we have uploaded some images to the Powerapps media. Next we tried to add an image to one contact using simple If-statement in the gallerys Image section:

If(DisplayName="Person Name1";'Person Name1';'Default Image')

NOTE: The image files are named after the employee as Firstname Lastname format.

This worked fine. However since we have many employees using If-statement or Switch-statement can cause a huge block of code:

Switch(DisplayName;
     "Person Name1";'Person Name1';
     "Person Name2";'Person Name2';
     "Person Name3";'Person Name3';
     ........and so on till we get to the end and we can declare the default value
     'Default Image'
)

Now imaging if we have to do this for +80 personnel that is changing constantly. There's no way we can keep tracking what changes we have to do and changing the code isn't really a best practice.

Is there any easier way to get the image without using Office 365 data? We haven't been able to set the name from DisplayName in side ' '. And this is pretty much causing a lot of headache to us since we have to use ' ' to tell the app to use the image. If we only could put DisplayName inside ' ' somehow.

3 REPLIES 3
v-xida-msft
Community Support
Community Support

Hi @tuuman,

Could you please share a bit more about your scenario?

Do you want to display profile picture for the Employees of your Org in the Gallery using Media files in your app without using Office 365 data?

Based on the needs that you mentioned, I afraid that there is no direct way to achieve your needs in PowerApps currently.

As an alternative solution, you could consider take a try to save the Media Image files and corresponding Employee Name (DisplayName) into a Collection, then within the Gallery, you could use LookUp function to retrieve the corresponding image based on DisplayName of each employee.

I have made a test on my side, please take a try with the following workaround:9.JPG

 

10.JPG

Set the OnStart proeprty of the first screen of my app to following:

ClearCollect(
    EmployeeImages,
    {DisplayName: "Barry Cao", Image: 'Barry Cao'},
    {DisplayName: "charlie Liao", Image: 'charlie Liao'},
    {DisplayName: "dan he", Image: 'dan he'},
    {DisplayName: "Test2", Image: Test2},
    {DisplayName: "Kris Dai", Image: 'Kris Dai'}
)

On your side, you should type:

ClearCollect(
          EmployeeImages;
          {PersonName: "Person Name1"; Image: 'Person Name1'};
          {PersonName: "Person Name2"; Image: 'Person Name2'};
          {PersonName: "Person Name3"; Image: 'Person Name3'};
          ...
)

Set the Items property of the Gallery to following:

Office365Users.SearchUser()

Within the Gallery, set the Image property of the Image control to following:

If(
!IsBlank(LookUp(EmployeeImages, DisplayName = ThisItem.DisplayName, Image)),
LookUp(EmployeeImages, DisplayName = ThisItem.DisplayName, Image),
SampleImage
)

On your side, you should type:

If(
!IsBlank(LookUp(EmployeeImages, PersonName = ThisItem.DisplayName, Image)),
LookUp(EmployeeImages, PersonName = ThisItem.DisplayName, Image),
'Default Image'
)

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your reply @v-xida-msft

 

Our original intend was to save images in media files and then call them in the gallery with certain names. What we thought we could do was to get ThisItem.DisplayName and inject that inside ' ' since the gallery image section required the usage of those single quotes. The problem is though if we put ThisItem.DisplayName inside ' ' Powerapps reads it as a file name and not as function call. If we put ThisItem.DisplayName without ' ' Powerapps reads it as a function but doesn't print image since DisplayName doesn't hold any. If we could somehow inject DisplayName inside ' ' we could achieve a much cleaner code that would automatically find corresponding image without the need of writing a new line of code. All what would left for us to is upload new image to the media.

 

Regarding to your workaround: Very interesting idea but ultimately it doesn't solve our problem. We still need to put huge amount code just to get collection. It would though clean up the code from the Gallery, but we could achieve same result with even less code by using Switch.

 

So ultimately what we want:

We want to get images without using Office 365 profile images. Therefore we added images to the mediafiles. We also want to make the code as short as possible by picking up name from DisplayName and search for corresponding image from media files. Only way we have succeed with this so far is creating If- and Switch-statements. Problem with these are they would be huge and end up being messy in the code. Creating collection would clean up the code from Gallery Image section but ultimately we still would have to manually input every item in the collection, making it huge and messy.

 

I hope this cleared a bit our situation.

I'm not marking solutions to this thread since I haven't received any solutions.

We decided to do workaround and just create bunch of Switch cases. It's not the prettiest or the most practical but it works the way we basicly want it. We're still open for other suggestions.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Top Solution Authors
Top Kudoed Authors
Users online (2,268)