cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kadd
Resolver III
Resolver III

Patching one line per multiple user

Hello,

 

hope you're all doing good.

 

So...what i'm trying to is to patch multiple users.

 

I have a form with an "Expert" field. this field is configured to accept multiple users.

I'm trying to create one item per user so i wrote something like ...

 

ForAll(

           Expert.SelectedItems,

           Patch( Users, Defaults(Users),{

                 Process : Process.Text,

                 Activity : Activity.Text,

                 Expert: Expert.Selected,

                 Function : Function.Selected

           })

)

 

let's say that i have 2 users in "Expert", I need 2 items to be created ...one for each user.

This formula create my 2 items but the Expert field is empty.

 

Would someone have an idea of what is wrong ?

 

Thanks a lot for your time

1 ACCEPTED SOLUTION

Accepted Solutions
Kadd
Resolver III
Resolver III

@BCBuizer , @C-Papa 

 

Aha !!! it works !!!!

 

I added "Table ()" around the Expert's result

 

ForAll(Expert.SelectedItems As SelectedPeople,
Patch( Users, Defaults(Users),
{
   Process : Process.Text,
   Activity : Activity.Text,
   Expert:
      Table({
          '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
          Claims: "i:0#.f|membership|" & SelectedPeople.Email,
          Department: "",
          DisplayName: SelectedPeople.DisplayName,
          Email: SelectedPeople.Email,
          JobTitle: ".",
          Picture: "."
    }),
    Function : Function.Selected
})

 

That's cool !!! 

 

Thanks a lot for your help !! 🙂

 

View solution in original post

8 REPLIES 8
BCBuizer
Super User
Super User

It seems you are trying to patch a record.

 

Can you try changing the code to something like the below to patch a value, rather than a record?

 

Expert: Expert.Selected.Name

 

C-Papa
Super User
Super User

what field type is the  Expert field in your database? a text field or a person / group choice field? 

Hello @BCBuizer  and @C-Papa ,

 

Thanks for your answers.

 

The Expert.Select.Name doesn't work. on one side i have a table and on the other it's text.

 

My field is a People picker field.

 

So i had the idea to collect the users first into a collection then use a ForAll to go through the items of that collection and apply the value coming from the collection to my "Expert" field. so i end up writing something like ...

 

ForAll(
        Expert.SelectedItems,
    Collect(
        CollExperts,
        {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Claims: "i:0#.f|membership|" & ThisRecord.Email,
            Department: "",
            DisplayName: ThisRecord.DisplayName,
            Email: ThisRecord.Email,
            JobTitle: ".",
            Picture: "."
        }
    )
);//endForAll

ForAll(

           CollExperts,
           Patch( Users, Defaults(Users),{
                 Process : Process.Text,
                 Activity : Activity.Text,
                 Expert:  ??
                 Function : Function.Selected
           })//EndPatch
)//endForAll

 

But then not sure that is correct (it collects my users for sure) ...I don't understand how to patch each "Expert" separately...

 

C-Papa
Super User
Super User

Try this

 

ForAll(Expert.SelectedItems As SelectedPeople,
Patch( Users, Defaults(Users),{Process : Process.Text,Activity : Activity.Text,Expert:

{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & SelectedPeople.Email,
Department: "",
DisplayName: SelectedPeople.DisplayName,
Email: SelectedPeople.Email,
JobTitle: ".",
Picture: "."
},Function : Function.Selected})

Hi @C-Papa ,

 

the error is saying " Expert does not match the expected type 'Table'.Found type 'Record' "

 

I don't think there's a need to add this extra step since zou mentioned initially the two rows are created, just not populated.

 

Therefore I think the issues is in how the Patch functino is used. I recently had similar issues and I think the below might get you your result:

Expert:{
            Claims: Expert.Selected.Claims,
            Department: Expert.Selected.Department,
            DisplayName: Expert.Selected.DisplayName,
            Email: Expert.Selected.Email,
            JobTitle: Expert.Selected.JobTitle,
            Picture: Expert.Selected.Picture
        }

 

 

@BCBuizer , hmm...the error message is still the same.

my people field (Expert) is set as mutliselection so it needs a table

Kadd
Resolver III
Resolver III

@BCBuizer , @C-Papa 

 

Aha !!! it works !!!!

 

I added "Table ()" around the Expert's result

 

ForAll(Expert.SelectedItems As SelectedPeople,
Patch( Users, Defaults(Users),
{
   Process : Process.Text,
   Activity : Activity.Text,
   Expert:
      Table({
          '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
          Claims: "i:0#.f|membership|" & SelectedPeople.Email,
          Department: "",
          DisplayName: SelectedPeople.DisplayName,
          Email: SelectedPeople.Email,
          JobTitle: ".",
          Picture: "."
    }),
    Function : Function.Selected
})

 

That's cool !!! 

 

Thanks a lot for your help !! 🙂

 

Helpful resources

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

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,132)