Hello you,
I'm trying to patch a user in a custom table. But the user table has no columns...
Sounds tricky here...
So far, I have this.
Patch(Junction_Idea_Users,Defaults(Junction_Idea_Users), { User_L: Office365Users.UserProfileV2(User().Email).id})
Solved! Go to Solution.
I have the following now :
Nevermind, fixed it. Wasn't the same columns...
Right! That is not what I was demonstrating in the suggested formula. In yours you are trying to set a (presumably numeric) column to a whole record - that is not a compatible type.
Setting that context variable over and over is not the best choice for your app.
If you are showing the Ideas in a Gallery, then you already have the ID of the Idea, so there is no need to look it up again.
For the User, you should look up their ID only once...like OnStart of the app.
So, based on that, first your OnStart would have this:
Set(glbUser, LookUp(Users, 'Primary Email' = User().Email))
And then for the Items property of your Gallery...you should already be using records from the Ideas table. So no need for lookup there.
Based on all of that, the formula for the OnSelect of the icon should be:
If(Self.Icon = Icon.ThumbsDown,
Patch(Junction_Idea_Users, {IdeaID: ThisItem.IdeaID, UserID: glbUser.UserID}),
RemoveIf(yourIdeaUserJunctionTable, IdeaID = ThisItem.IdeaID && UserID = glbUser.UserID)
)
And the Icon property of the Icon should be:
If(LookUp(Junction_Idea_Users, IdeaID = ThisItem.IdeaID && UserID = glbUser.UserID, true),
Icon.ThumbsDown,
Icon.ThumbsUp
)
I do not know that actual ID/Key from your Idea and User tables, so replace the IdeaID and UserID in the above formulas to the appropriate column with that value.
Good evening,
Do you have an alternative solution for this ?
Patch(Junction_Idea_Users, {IdeaID: ThisItem.IdeaID, UserID: glbUser.UserID}),
The reason is because you can't access IdeaID or UserId directly as you need to go through the lookup first.
Gotcha! I had to use the contextupdate but it works like a charm!
Small correction on the removeif statement, replace && by And if you do not want the whole list that match either or to be flushed 😛
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
193 | |
69 | |
49 | |
41 | |
30 |
User | Count |
---|---|
254 | |
120 | |
96 | |
91 | |
78 |