cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Power Participant
Power Participant

Person column SharePoint, save form

Hi i just want to check if i'm doing this the correct way.

 

Everything works i can select a user or save the current user and it is saved to the person column in SharePoint, but is this the correct way of doing it?

 

I have a SharePoint column named Person1.

In powerapps i have this column as a form.

 

varUser = User().Email



Items = Office365Users.SearchUser({searchTerm: DataCardValue2.SearchText})

DefaultSelectedItems = Office365Users.UserProfile(varUser)



Update = 

{
DisplayName: DataCardValue2.Selected.DisplayName,
Claims: "i:0#.f|membership|" & DataCardValue2.Selected.Mail,
Email: DataCardValue2.Selected.Mail
}
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@JimmyWork 

Yes, that is correct, but you're kind of trying to do something that is already built in.

 

I just answered a similar question on this earlier that you might want to review.

 

For your formulas, you will never have a selected person.  The reason is because you are filtering (searching) your items list and the DefaultSelectedItems will never match anything (because there will be nothing based on the Search).  I am referring to if you go back and edit the record.  The SearchText will be blank (and you can't set it) and so it will have no items.

 

What you can consider changing is to put this in your Items formula:

Choices([@yourDataSourceName].Person1)

 

Then set the DefaultSelectedItems property to:

Coalesce(Parent.Default, 
    With({profile: Office365Users.UserProfileV2(User().Email)},
       {  
       Claims:"i:0#.f|membership|" & profile.mail,  
       DisplayName:profile.displayName,  
       Department:profile.department,  
       Email:profile.mail,  
       JobTitle:profile.jobTitle,  
       Picture:"."  
       }
    )
)

 

Then for your DataCard Default property, set it to : ThisItem.Person1

And finally for your Update on the DataCard, set it to : DataCardValue2.Selected

 

This will give you a default for a "new" record to be the current user and then an ability to actually show that user again selected when you return to edit the record.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@JimmyWork 

Yes, that is correct, but you're kind of trying to do something that is already built in.

 

I just answered a similar question on this earlier that you might want to review.

 

For your formulas, you will never have a selected person.  The reason is because you are filtering (searching) your items list and the DefaultSelectedItems will never match anything (because there will be nothing based on the Search).  I am referring to if you go back and edit the record.  The SearchText will be blank (and you can't set it) and so it will have no items.

 

What you can consider changing is to put this in your Items formula:

Choices([@yourDataSourceName].Person1)

 

Then set the DefaultSelectedItems property to:

Coalesce(Parent.Default, 
    With({profile: Office365Users.UserProfileV2(User().Email)},
       {  
       Claims:"i:0#.f|membership|" & profile.mail,  
       DisplayName:profile.displayName,  
       Department:profile.department,  
       Email:profile.mail,  
       JobTitle:profile.jobTitle,  
       Picture:"."  
       }
    )
)

 

Then for your DataCard Default property, set it to : ThisItem.Person1

And finally for your Update on the DataCard, set it to : DataCardValue2.Selected

 

This will give you a default for a "new" record to be the current user and then an ability to actually show that user again selected when you return to edit the record.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

@RandyHayes Thank you for answering

 

Thank you so basically the only part i need to change is the DefaultSelectItems, everything else is straight out of the box 🙂

@JimmyWork 

Yes, that is correct.  PowerApps will recognize certain complex types in an EditForm and will do all the "magic" to make it update properly.  So usually, it is just about overriding some properties (in this case the default) while still observing the signature that lets PowerApps maintain its magic.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

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

Top Solution Authors
Top Kudoed Authors
Users online (2,005)