web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / When the "star" is cli...
Power Apps
Suggested Answer

When the "star" is clicked - make it yellow

(1) ShareShare
ReportReport
Posted on by 44

Hello,

In my Power App, there is a "Star" icon (which doesn't have all the events like other icons). When I click on the Star, it should turn gold (the function is already provided - clicking adds the selected item to the Favorites list for the current user). Also, the user must be able to remove the selected item from the Favorites list by clicking on the "X," and the star should return to its colorless state. Thank you for your help! 

  • Suggested answer
    WarrenBelz Profile Picture
    156,538 Most Valuable Professional on at
    Hi  stayclassy,
    You need a field in your Data Source (I will call it Favourite here) - Text is easiest, Then OnSelect of the Star icon (this allows unselecting as you have specified)
    Patch(
       DataSource,
       ThisItem,
       {
          Favourite:
          If(
             ThisItem.Favourite = "Yes",
             "No",
             "Yes"
          )
       }
    )
    Then the Fill of the Icon (I am assuming it is currently White)
    If(
       ThisItem.Favourite = "Yes",
       Color.Yellow,
       Color.White
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,970 Super User 2026 Season 2 on at
    HI,
     
    You have posted in the Pro Dev & ISV so the expectation is your are a pro and stuck on something.
     
    I am not sure if you are using a Canvas App or Model driven. You have provided no details at all about names of controls, or pictures of your app.
     
    Are you trying to ask for help with the help or building a PACF Component? I am not sure at all.
     
    Also, you should have an app with basic functionality and please post this in the Power Apps, Building Apps Section
  • Suggested answer
    Nandit Profile Picture
    1,568 Moderator on at
    Hi @stayclassy
     
    I have been able to do this by creating two collections "Documents" and "User Favorites". Please see below. 

    Documents
    ClearCollect(
        Documents,
        {
            Doc: "Doc1.docx",
            ID: 1
        },
        {
            Doc: "Doc2.docx",
            ID: 2
        },
        {
            Doc: "Doc3.docx",
            ID: 3
        },
        {
            Doc: "Doc4.docx",
            ID: 4
        }
    );
     
    User Favorites (Replace placeholder email addresses)
    ClearCollect(
        User_Favorites,
        {
            Email: "----E-Mail Address---",
            Favorites: "1,2"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "3,2"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "1,3"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "4,2"
        }
    );
    
    Documents Gallery
    Gallery Items: Documents (Collection)
     
    Star Icon Fill
    If(
        ThisItem.ID in Split(
            LookUp(
                User_Favorites,
                Email = User().Email
            ).Favorites,
            ","
        ),
        Color.Gold,
        Color.White
    )
    Star Icon OnSelect (If user does not exist in collection, patch new record otherwise update the existing record)
    Patch(
        User_Favorites,
        If(
            IsBlank(
                LookUp(
                    User_Favorites,
                    Email = User().Email
                )
            ),
            Defaults(User_Favorites),
            LookUp(
                User_Favorites,
                Email = User().Email
            )
        ),
        {
            Favorites: If(
                ThisItem.ID in Split(
                    LookUp(
                        User_Favorites,
                        Email = User().Email
                    ).Favorites,
                    ","
                ),
                Concat(
                    Filter(
                        Gallery1.AllItems,
                        Star1.Fill = Color.Gold && !(ID = ThisItem.ID)
                    ),
                    ID,
                    ","
                ),
                Concatenate(
                    Concat(
                        Filter(
                            Gallery1.AllItems,
                            Star1.Fill = Color.Gold && !(ID = ThisItem.ID)
                        ),
                        ID,
                        ","
                    ),
                    ",",
                    ThisItem.ID
                )
            )
        }
    );
     
    User Favorites Label (Just to see the favorites of current user)
    LookUp(User_Favorites, Email = User().Email).Favorites
     
     
    If this answers your query, please mark this response as the answer.
    If this was helpful. please leave a like. Thanks!
     
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard