web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Pre-populate combo box...
Power Apps
Unanswered

Pre-populate combo box control with logged in user

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

 

I am working on an app where I want to capture the logged in user as a person type field in SharePoint versus a Text field. To this end, I've inserted a combobox control which I would like to default to the current logged in user. I have a variable set in OnStart of the app that captures the logged in user and I've established an Office365Users connection. I've found videos on how to default to the logged in user when using a form control, but I haven't been able to find one for a combobox box alone in a Collection scenario.

 

ComboBoxStripSS.png

As you can see, the idea is that users add expenses via controls in the top line that are collected in the Collection below (scroll down to view an example).  Once I have the combobox working, I plan to hide the control. I just want it working in the background, collecting the user's identity to the Collection and then patching it back to a person column in the SharePoint data source when the Submit Expenses button is clicked. I think I can get the Collect and Patch statements correct, but I would appreciate help getting the logged in user populated in the control. My current formula attempts are noted below. Thank you.

 

OnStart

Set(varUser,User())

 

ComboBox Items Property

Office365Users.MyProfileV2({Name:varUser.FullName})

 

CB Default Property

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("1:0#.f|membership|",varUser.Email),
DisplayName:varUser.FullName,
Email:varUser.Email}

 

CB DefaultSelected Items Property

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("1:0#.f|membership|",varUser.Email),
DisplayName:varUser.FullName,
Email:varUser.Email}

 

Here is a screenshot of what the Collection looks like as you start to add items. Many thanks to Randy Hayes for his advice on how to add items from the top row into the Collection and then write them back to the data source. Teresa

 

ExpenseCollectionSS.png

 

 

 

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @tagustin2020 ,

    Just one initial question - why are you using a Combo Box with just one Selected Item - actually as the data is always the same, why use a control at all - just Patch those values (in the DefaultSelectedItems) back to your list field.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • tagustin2020 Profile Picture
    on at

    @WarrenBelz 

     

    Hi Warren,

     

    The short answer is that I'm a newbie and don't know what I'm doing LOL. You make an excellent point. I will give you recommendation a try over the weekend and let you know if I have any follow-up questions. 

     

    Thanks so much for your prompt help!

    Teresa

  • tagustin2020 Profile Picture
    on at

    @WarrenBelz 

     

    Hello Warren,

     

    Per your suggestion, I removed the combo box control from the app and added the Admin Person patch to the OnSelect of my Collect button. I'm not getting any formula errors, but the name of the logged in user is not being written back to the SharePoint data source. What did I miss? Before I decided a person column was the way to go, I was writing the name and email of the user back to the SharePoint list text columns (color-coded green below). I know I don't need the name text column once I get the person field going and I don't think I need the email text column either, but can you confirm that? As you know, I am sending an immediate confirmation email to the user when they submit their expenses.

     

    Collect(
    colExpenses,
    {
    TransDate: dpTransDateAdd.SelectedDate,
    BudgetCategory: ddCatAdd.Selected.Title,
    SubCategory: ddSubCatAdd.Selected.Result,
    Title: tiMerchantAdd.Text,
    ExpenseAmount: Value(tiAmountAdd.Text),
    Description: tiDescriptionAdd.Text,
    Admin:
    {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:Concatenate("1:0#.f|membership|",varUser.Email),
    DisplayName:varUser.FullName,
    Email:varUser.Email},
    AdminName: varUser.FullName,
    AdminEmail: varUser.Email,
    Year: Year(Now()),
    Quarter: RoundUp(Month(dpTransDate.SelectedDate)/3,0),
    Month: Month(Now())
    }
    );
    Reset(dpTransDateAdd);
    Reset(ddCatAdd);
    Reset(ddSubCatAdd);
    Reset(tiMerchantAdd);
    Reset(tiAmountAdd);
    Reset(tiDescriptionAdd)

     

    A summarized version of my Submit Expenses button OnSelect is:

     

    Play the spinner;

    Collect(Expenses,colExpenses);

    Send the email summary (per the other issue you helped with);

    Clear(colExpenses);

    Navigate to the homescreen,

    Stop playing the spinner

     

    Thank you Warren. Teresa

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @tagustin2020 

    Your Admin record is not providing all of the columns needed to properly assign a person.

     

    Consider the following change to your Formula:

     

    Collect(colExpenses,
     {
     TransDate: dpTransDateAdd.SelectedDate,
     BudgetCategory: ddCatAdd.Selected.Title,
     SubCategory: ddSubCatAdd.Selected.Result,
     Title: tiMerchantAdd.Text,
     ExpenseAmount: Value(tiAmountAdd.Text),
     Description: tiDescriptionAdd.Text,
     Admin:
     {
     Claims: "i:0#.f|membership|" & Lower(varUser.Email),
     DisplayName: varUser.FullName,
     Department: "", 
     Email: varUser.Email, 
     JobTitle: ".", 
     Picture: "."
     },
     AdminName: varUser.FullName,
     AdminEmail: varUser.Email,
     Year: Year(Now()),
     Quarter: RoundUp(Month(dpTransDate.SelectedDate)/3,0),
     Month: Month(Now())
     }
    );
    
    Reset(dpTransDateAdd);
    Reset(ddCatAdd);
    Reset(ddSubCatAdd);
    Reset(tiMerchantAdd);
    Reset(tiAmountAdd);
    Reset(tiDescriptionAdd)

     

     

    I hope this is helpful for you.

  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @tagustin2020 ,

    As @RandyHayes has pointed out (I am just back in my time zone now), more details are required for a Person field - the full ones I use (rarely as I do not use these fields any more - you might consider going back to your text fields) is 

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

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • tagustin2020 Profile Picture
    on at

    Thank you very much Warren! It is working now 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard