I'm trying to update a record using the patch function but I'm getting a validation warning due to the User().Email
This is my formula:
Patch(Actors,First(Filter(Actors,ID=SharePointIntegration.Selected.ID && Action="Approval" && Decision="Pending" && If(varPrompt=8,Phase_Name="Initial Validation",Person1.Email=User().Email)))
How would you patch a record with multiple conditions in a filter when using the User command for a person/people field
Solved! Go to Solution.
Its because you are using the embedded function. Just save the user email to a variable and use the variable instead of the function. Something like this, although you can also save it in the App OnStart since it doesn't change.
Set(CurrentUser, User().Email);Patch(Actors,First(Filter(Actors,ID=SharePointIntegration.Selected.ID && Action="Approval" && Decision="Pending" && If(varPrompt=8,Phase_Name="Initial Validation",Person1.Email=CurrentUser)))
I believe the reason why your formula cannot be delegated is because you are using a variable 'varPrompt' inside of FILTER. We must move the IF condition outside of the PATCH for this reason.
If(varPrompt=8,
Patch(
Actors,
First(
Filter(
Actors,
ID=SharePointIntegration.Selected.ID
&& Action="Approval"
&& Decision="Pending"
&& Phase_Name="Initial Validation"
)
)
),
Patch(
Actors,
First(
Filter(
Actors,
ID=SharePointIntegration.Selected.ID
&& Action="Approval"
&& Decision="Pending"
&& Person1.Email=User().Email
)
)
)
)
My intuition tells me your next question will be "how can I make this code more compact". I am afraid I am not aware of any way to that. At least it wasn't too long to write because I could simply copy + paste from the code you already have 🙂
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Its because you are using the embedded function. Just save the user email to a variable and use the variable instead of the function. Something like this, although you can also save it in the App OnStart since it doesn't change.
Set(CurrentUser, User().Email);Patch(Actors,First(Filter(Actors,ID=SharePointIntegration.Selected.ID && Action="Approval" && Decision="Pending" && If(varPrompt=8,Phase_Name="Initial Validation",Person1.Email=CurrentUser)))
I believe the reason why your formula cannot be delegated is because you are using a variable 'varPrompt' inside of FILTER. We must move the IF condition outside of the PATCH for this reason.
If(varPrompt=8,
Patch(
Actors,
First(
Filter(
Actors,
ID=SharePointIntegration.Selected.ID
&& Action="Approval"
&& Decision="Pending"
&& Phase_Name="Initial Validation"
)
)
),
Patch(
Actors,
First(
Filter(
Actors,
ID=SharePointIntegration.Selected.ID
&& Action="Approval"
&& Decision="Pending"
&& Person1.Email=User().Email
)
)
)
)
My intuition tells me your next question will be "how can I make this code more compact". I am afraid I am not aware of any way to that. At least it wasn't too long to write because I could simply copy + paste from the code you already have 🙂
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
I had to do a combination of both. Set variable for User().Email and splitting the patching with the if condition.
User | Count |
---|---|
209 | |
94 | |
84 | |
49 | |
39 |
User | Count |
---|---|
264 | |
104 | |
104 | |
61 | |
59 |