cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

Delegation warning when patching

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

2 ACCEPTED SOLUTIONS

Accepted Solutions
Dual Super User III
Dual Super User III

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)))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Super User III
Super User III

@lui

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."

View solution in original post

3 REPLIES 3
Dual Super User III
Dual Super User III

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)))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Super User III
Super User III

@lui

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."

View solution in original post

I had to do a combination of both. Set variable for User().Email and splitting the patching with the if condition.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (63,558)