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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Manually update SP dro...
Power Apps
Answered

Manually update SP dropdown value

(0) ShareShare
ReportReport
Posted on by

Hi there. I have a form generated by a SP list. One of these fields is a drop down from the SP side. I have set the Default and DefaultSelectedItems to a variable lets say myvar and onvisible of my screen, I am trying something like this:

 

UpdateContext({
myvar: {Text: Office365Users.MyProfile().City, Val: Office365Users.MyProfile().City}
});

 

but its not working as I would like. Any ideas? I tried single value but because its a drop down from SP, it requires a table attribute inside the updateContext.

 

Thank you in advance

Categories:
  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @pm4698 ,

     

    If your combobox has below attached configuration mapped to city please use below code. 

    In DefaultSelectedItems : 
    
     {
     City:Office365Users.MyProfileV2().city
    }

     

    PG_WorXz10_0-1631530843929.png

     

     

    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.

  • pm4698 Profile Picture
    on at

    Actually I have a DataCardValue not a combobox because its generated by the SP list. And inside the Data Source I have my SP list column. Tried that and it didn't Work. So my column's name is City yes if that helps. Also I know that if I were to update a SP Person field, I would do something like:

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

     

    Which is an array with all Person attributes. What about a simple SP drop down column inside a power app?

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @pm4698 ,

     

    Thanks for the details.

     

    I need some more information the the default value which you want to set is of a people picker or simple SharePoint choice column type. Basically I want the details about the control is it dropdown or not ? What is the item property of that control and in SharePoint what is the column type ? 

  • pm4698 Profile Picture
    on at

    So, I have a SP list which is type of Choice. Column's name is City. I have inserted lots of choices in there. So, in power apps, I created a form from this SP list. In my City DataCard, Data source is from SharePoint. Items value is:

    Choices([@'My SP List'].City) and I have set under default and defaultselecteditems a variable called myvar.

     

    So, what I need is to update this City dropdown when screen is visible like this:

     UpdateContext({ 
     myvar: {City: Office365Users.MyProfile().City}
     });

    This brings the correct value which actually corresponds to one of the values of the dropdown and its like I need to tell somehow: Find the dropdown value which matches  Office365Users.MyProfile().City and select it

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @pm4698 ,

     

    Please try updating the code. Let me know if it helps

    OnScreenVisible or OnAppStart: 
    
    Set(myvar,Office365Users.MyProfile().City)
    
    
    On DropDown DefaultItems 
    
     {
     Value: myvar
     
     } 
    

     

     

    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.

  • pm4698 Profile Picture
    on at

    Tried that but its not working

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @pm4698 ,

     

    Could share the error message which you are getting ? 

  • pm4698 Profile Picture
    on at

    Actually I am not getting an error message at all. Also tried using 

    Office365Users.MyProfile().City

    inside a label and it brings correct value (for me its Athens). And inside the City drop down there is a choice Athens but its like its not being updated with that value

  • Verified answer
    PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @pm4698 ,

     

    Ok, another try.

     

    Please try the below in your dropdown.  

     

     {
     Value: Office365Users.MyProfile().City
     
     } 

     

     

    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.

     

  • pm4698 Profile Picture
    on at

    This is working yes!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard