Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Change the color of a rectangle present in a gallery after a patch()

(0) ShareShare
ReportReport
Posted on by

Hi there, 

 

I have a gallery that contains multiple zones. In each zone, there is a gray rectangle.

Is it possible to change the color of the gray rectangle at the top after using the patch() function, without changing the color of the other rectangle at the bottom?

 

ArnaudH_0-1678436344203.png

 

Thank you for your help

Categories:
  • ArnaudH Profile Picture
    on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    Thank you for the response, I see the logic!

  • Verified answer
    WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    @ArnaudH ,

    I cannot see your data, so am only guessing here - as an example if you had the field LinkA in List A and LinkB in List B and they had the same value (a "key" field if you like) and the changed field was (to use my previous example) is called Status. If there was only one record in List B matching the record you want to colour in List A, then this is easy

    If(
     LookUp(
     'List B'
     LinkB = ThisItem.LinkA
     ).Status = "Completed",
     Color.Green,
     Color.Grey
    )

    If there are multiple matches in list A to the changed item in List B, then all those items in the gallery will turn green. There has to be a one-to-one relationship for this to work.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • ArnaudH Profile Picture
    on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    I don't quite understand the solution, do I need to import a value from List B to List A during the patch()?

    It's also possible that multiple values in List B are the same. How do you handle these cases?

  • WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    @ArnaudH ,

    This is going to be more complex if at all possible. You are going to need a field in List A "linked" to the record in List B by a common value field and if you look it up for the changed value in List B, it is the only record in List A that will reflect the change (or more than one record in the gallery will turn green)

  • ArnaudH Profile Picture
    on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    Thank you for the quick response.

    I had already tried this solution but the problem is as follows: The information displayed in the gallery comes from a SharePoint list 'A', and the Patch() function writes to a SharePoint list 'B'. How is it possible to display data from two different sources in the same gallery?

  • WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: Change the color of a rectangle present in a gallery after a patch()

    Hi @ArnaudH ,

    You need to patch a value to the record that you can then test for being present and the set the TemplateFill of the gallery accordingly. So for instance, if you changed a field called Status to Completed and wanted all completed fields to have a Green background, the TemplateFill of the Gallery would be

    If(
     ThisItem.Status = "Completed",
     Color.Green,
     Color.Grey
    )

     

    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.

    MVP (Business Applications)   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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,631 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,991 Most Valuable Professional

Leaderboard