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 / Need help in small cod...
Power Apps
Answered

Need help in small coding error in Power App SharePoint form customization

(0) ShareShare
ReportReport
Posted on by 142

Hi , I am working on SharePoint power App Form customization. Which involves storing user responses on item like and unlikes status and count.

 

I am getting a coding error under f(x) section of Onselect on Thumbs up icon in one of my section and cant figure it out what causing it.  below is the snap shot of it. there ae two indicators in the pic which are pointing to error.

 

If you need more info to understand the issue, please let me know. thanks

 

Audi86_0-1692278148756.png

 

Categories:
  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    Hi!

     

    From the looks of things, it's just a small syntax error.

    Just to make sure we're on the same page, in the section of code with the errors, if the lookup to LikeResponses is blank, you want to patch to LikeResponses and then patch to LikeCount? 

     

    Going over the code, it looks like you're trying to surround these two patch functions in brackets to have them be performed together?

    The syntax for this is slightly different. Assuming you're using an If function here, anything you want to be grouped together as one argument to the if statement should be separated with semicolons ";", and anytime you want to separate arguments, use commas.

     

    Hopefully you're able to get it from this, otherwise could you send the full code here? Your earlier screenshot seems to be a little cutoff, so I've had to make some assumptions.

     

    Let me know 🙂

  • Audi86 Profile Picture
    142 on at

    @madlad yes you got it right on. LikeResponses and LikesCount are two seperate lists as well.

     

    I tried to play with the comma and Semi colon but cant make it.

    her is the code if you can see where i am missing:

     

    If(

    SharePointIntegration.Selected.'Created By'.Email = User().Email,

    Notify("You can't like your own post!", NotificationType.Error),

     

    IsBlank(LookUp(LikeResponses, UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID))),

    (

    Patch(LikeResponses, Defaults(LikeResponses), {UserID: User().Email, Title: Text(SharePointIntegration.Selected.ID), LikeStatus: 1});

    Patch(LikesCount, LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), {TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) + 1})

    ), (

    Patch(LikeResponses, Defaults(LikeResponses), {UserID: User().Email, Title: Text(SharePointIntegration.Selected.ID), LikeStatus: 1});

    Patch(LikesCount, LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), {TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) + 1})

    ),

    LookUp(LikeResponses, UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)).LikeStatus = 1,

    (

    Patch(LikeResponses, LookUp(LikeResponses, UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)), {LikeStatus: 0});

    Patch(LikesCount, LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), {TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) - 1})

    ),

    LookUp(LikeResponses, UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)).LikeStatus = 0,

    (

    Patch(LikeResponses, LookUp(LikeResponses, UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)), {LikeStatus: 1});

    Patch(LikesCount, LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), {TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) + 1})

    )

    )

  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    I see he problem here - you need to remove the brackets around the multiple patch functions. However, it looks like potentially your order of operations in your if function was slightly off? There were two identical blocks of code(2 patch functions each) separated by a comma in the middle - since these won't work with the if function I removed the latter. Try this code and let me know if it works as desired. I haven't tested it but I did remove the extra brackets which could have been to blame.

     

    If(
     SharePointIntegration.Selected.'Created By'.Email = User().Email,
     Notify("You can't like your own post!", NotificationType.Error),
     IsBlank(
     LookUp(
     LikeResponses, 
     UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)
     )
     ),
     Patch(
     LikeResponses, 
     Defaults(LikeResponses), 
     {
     UserID: User().Email, 
     Title: Text(SharePointIntegration.Selected.ID), 
     LikeStatus: 1
     }
     );
     Patch(
     LikesCount, 
     LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), 
     {
     TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) + 1
     }
     ),
     LookUp(
     LikeResponses, 
     UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)
     ).LikeStatus = 1,
     Patch(
     LikeResponses, 
     LookUp(
     LikeResponses, 
     UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)
     ), 
     {
     LikeStatus: 0
     }
     );
     Patch(
     LikesCount, 
     LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), 
     {
     TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) - 1
     }
     ),
     LookUp(
     LikeResponses, 
     UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)
     ).LikeStatus = 0,
     Patch(
     LikeResponses, 
     LookUp(
     LikeResponses, 
     UserID = User().Email && Title = Text(SharePointIntegration.Selected.ID)
     ), 
     {
     LikeStatus: 1
     }
     );
     Patch(
     LikesCount, 
     LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)), 
     {
     TotalLikes: Value(LookUp(LikesCount, Title = Text(SharePointIntegration.Selected.ID)).TotalLikes) + 1
     }
     )
    )

     

     

  • Audi86 Profile Picture
    142 on at

    @madlad Thanks alot. the error is gone and first part of code which involves LikeResponses and toggling feature for same user is working now. But unfortunately, LikesCount is not updating or getting any entries. But I think I can take from here 🙂

  • madlad Profile Picture
    2,637 Moderator on at

    Sounds good, glad you've got the errors sorted! 🙂

    I've accepted the solution to this one so others will be able to find it in the future easier.

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 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard