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

Button to assign user (people picker field)

Hello everyone, is there a way that i can click a button to assign based on logged in user?

 

i can get the default logged in user to work but cant get it to work when you click on a button (i would rather not have it default)

i have a people picker field called  'Approved by",

 

does anyone know how to get it to work that if you press the button it will update the 'Approved by:" to the current logged in user?

 

what i am using for logged in user 

{  

'@odata.type'"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  

DisplayName:User().FullName,  

Claims:"i:0#.f|membership|" & Lower(User().Email),  

Department:"",  

Email:User().Email,  

JobTitle:"",  

Picture:""  

}

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@vandam2 

No problem!

 

I am not sure how your status factors into any of this or if you are just providing as reference, but for your original question...

On the Button OnSelect action, set the following formula:

With(User(),
    UpdateContext({lclUser:
        {  Claims:"i:0#.f|membership|" & Lower(Email),  
           DisplayName: FullName,  
           Department:"",  
           Email: Email,  
           JobTitle:"",  
           Picture:""  
        }
    })
)

 

Then in the DefaultSelectedItems property of your combobox, set to the following:

lclUser

 

I should have also asked if you already have a DefaultSelectedItems property!!  If so, then change the formula to:

Coalesce(lclUser, <yourCurrentDSIformulaHere>)

 

Just remember to do an UpdateContext({lclUser: Blank()}) at some point...like the screen OnHidden action, or whatever is applicable to your design.

 

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

8 REPLIES 8
RandyHayes
Super User
Super User

@vandam2 

Are you looking to have a combobox reflect the current user when the button is pressed or are you trying to immediately write that value to the datasource?

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

thank you for your quick reply, i would like it to update the combo box first, i have a separate button for them to hit to update the record, i would actually love to have the one button update a status (dropdown) and the assigned to (people picker) at the same time if possible

RandyHayes
Super User
Super User

@vandam2 

What is the Items property of your Combobox (I assume it is a combobox!)

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

People Picker (combo box) - Name is 'Approved by RAD'

Status Dropdown (changed to radio button) - Name is 'RAD Status'

RandyHayes
Super User
Super User

@vandam2 

Please let me know what the Items property of the 'Approved by RAD' combobox is.

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

sorry about that Randy,

People Picker -  ITEM = "Choices('Protocol Change Intake'.'Approved by RAD')"

RAD Status - ITEM = "Choices('Protocol Change Intake'.'RAD Status')"

 

thanks for your help with this, very much appreciate it 

RandyHayes
Super User
Super User

@vandam2 

No problem!

 

I am not sure how your status factors into any of this or if you are just providing as reference, but for your original question...

On the Button OnSelect action, set the following formula:

With(User(),
    UpdateContext({lclUser:
        {  Claims:"i:0#.f|membership|" & Lower(Email),  
           DisplayName: FullName,  
           Department:"",  
           Email: Email,  
           JobTitle:"",  
           Picture:""  
        }
    })
)

 

Then in the DefaultSelectedItems property of your combobox, set to the following:

lclUser

 

I should have also asked if you already have a DefaultSelectedItems property!!  If so, then change the formula to:

Coalesce(lclUser, <yourCurrentDSIformulaHere>)

 

Just remember to do an UpdateContext({lclUser: Blank()}) at some point...like the screen OnHidden action, or whatever is applicable to your design.

 

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hello Randy, that worked like a charm, thanks so much, 

 

what does the UpdateContext({lclUser: Blank()}) do?

and do i add it to the screen OnHidden action? 

does it reset the variable?

 

thanks again.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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