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

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
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
        }

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,818)