zach wilcox
zach wilcox

Reputation: 75

Implement like button in power apps

I am trying to implement a like feature in Microsoft power apps. I am having an issue when pressing the like button I am receiving the error

The type of this argument "LikedBy" does not match the expected type "Record" found type "text" instead. 

The code I am using is

Patch(
ProposalLikes,
Defaults(ProposalLikes),
{   
    ThemeID: ThisItem.ID,
    Liked: 1,
    LikedBy: User().Email
}

)

and my structure data list looks like IMage

does anyone know why I am receiving this error?

Upvotes: 0

Views: 1282

Answers (1)

SeaDude
SeaDude

Reputation: 4405

It appears that LikedBy is a Person-type column in the Sharepoint list. If so, it is a Record data type whereas User().Email is a Text data type. It can be tempting to use User() to patch Person-type columns, but the schemas don't match.

Person-type Column Schema (Sharepoint):

{         
  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
  Claims:"i:0#.f|membership|[email protected]",
  Department:"",
  DisplayName:"",
  Email:"",
  JobTitle:"",
  Picture:""
}

To Patch a Person-type Column, Try this:

Patch(
    ProposalLikes,
    Defaults(ProposalLikes),
    {   
        ThemeID: ThisItem.ID,
        Liked: 1,
        LikedBy: 
        {
          '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
           Claims:"i:0#.f|membership|" & User().Email,
           Department:"",
           DisplayName:User().FullName,
           Email:User().Email,
           JobTitle:"",
           Picture:""
        }
    }
)

Upvotes: 0

Related Questions