cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rmclaughlin
Frequent Visitor

Replacing a User in a Person Field During Patch (to SharePoint)

I have 2 functions. One works and one doesn't, and I don't understand why.

 

 

 

ForAll(
    RenameColumns(
        collection_1,
        "ID",
        "GalleryID"
    ),
    Patch(
        SharePointList1,
        LookUp(
            SharePointList1,
            ID = GalleryID
        ),
        {
            Approvers:
                Ungroup(
                    Table(
                        {
                            Item: Table(
                                {
                                    Claims: "i:0#.f|membership|" & Lower(O365ComboBox.Selected.Mail),
                                    DisplayName: O365ComboBox.Selected.DisplayName,
                                    Email: O365ComboBox.Selected.Mail,
                                    JobTitle: "",
                                    Picture: "",
                                    Department: ""
                                }
                            )
                        },
                        {
                            Item: Filter(
                                Approvers,
                                Email <> OldUser.Selected.Mail
                            )
                        }
                    ),
                    "Item"
                )
        }
    )
);

 

 

 

 

Does NOT Work. The error that shows up is that "Approvers" is not an available filter option where marked with "//Error ="

 

 

 

ForAll(
    Collection_FileSPIDs,
    Patch(
        SharePointLibrary,
        LookUp(
            SharePointLibrary,
            ID = FileSPID
        ),
        {
            Approvers:
                Ungroup(
                    Table(
                        {
                            Item: Table(
                                {
                                    Claims: "i:0#.f|membership|" & Lower(O365ComboBox.Selected.Mail),
                                    DisplayName: O365ComboBox.Selected.DisplayName,
                                    Email: O365ComboBox.Selected.Mail,
                                    JobTitle: "",
                                    Picture: "",
                                    Department: ""
                                }
                            )
                        },
                        {
                            Item: Filter(
                                Approvers, //ERROR = Field not valid. Approvers not recognized.
                                Email <> O365ComboBoxOldUser.Selected.Mail
                            )
                        }
                    ),
                    "Item"
                )
            
        }
    )
);

 

 

 

^it also says a lot of other errors, such as the Filter and Patch and Table having issues with invalid stuff. So I narrowed it down tot he simplest version of just removing the selected user (filtering them out):

 

 

 

ForAll(
    collectionDocIDs,
    Patch(
        SharePointLibrary,
        LookUp(
            SharePointLibrary,
            ID = DraftSPID
        ),
        {
            Approvers:
               Ungroup(
                    Table(
                        {
                            Item: Filter(
                                Approvers,
                                Email <> O365ComboBox.Selected.Mail
                            )
                            
                        }
                    ),
                    "Item"
                )
            
        }
    )
);

 

 

 

 

And this doesn't work either. It DOES recognize that "Approvers" is real when telling it where to patch the info, but it then doesn't recognize the approvers inside the filter. the only thing I can think of is that in the example that works, the collection is essentially a filtered version of the list I'm patching back to, whereas in the second and third example, the collection is just a list of Document IDs that I use to lookup which item to patch to. 

1 ACCEPTED SOLUTION

Accepted Solutions
rmclaughlin
Frequent Visitor

Ugh. Never mind. Turns out that filter isn't on the destination value but rather on the collection that is being run through by the For All, so I had to add a step to use the IDs to actually fetch the draft files into a dedicated collection and then use that new collection for the For All loop.

View solution in original post

1 REPLY 1
rmclaughlin
Frequent Visitor

Ugh. Never mind. Turns out that filter isn't on the destination value but rather on the collection that is being run through by the For All, so I had to add a step to use the IDs to actually fetch the draft files into a dedicated collection and then use that new collection for the For All loop.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,776)