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 / Set Default Value for ...
Power Apps
Answered

Set Default Value for Lookup Field in New Form

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

My project is an inventory management system, using two SharePoint lists; TBL_Locations and TBL_Assets. TBL_Assets has a lookup column called "LocationNumber" to a column in Locations called "LocationNumber".

 

I have created a standard app from the TBL_Locations list, and added a gallery to the second screen which shows the assets for the specified location.

 

I've added a button which opens the form to create a new asset. It doesn't really make sense to have a user select the LocationNumber manually since they have already selected a location to be working from, so I'd like to have that field automatically populate based on the Screen_Location.Selected.LocationNumber value.

 

However this doesn't appera to be quite a straightforword as I would expect, and I haven't been able to follow the other discussions on similar topics in this forum to achieve this goal.

 

Cheers,

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi Kfesenko,

     

    Is Screen_Location a screen with a Gallery control?

     

    Do you want to create a NewForm to add new records to Assets list? And on the NewForm, you have a Dropdown control that you that you want to show the LocationNumber based on the Screen_Location.Selected automatically without selecting from the drop down items.

     

    Please feel free correct me if I misunderstand you.

     

    Best regards,
    Mabel Mao

  • Verified answer
    Tom_Slosse Profile Picture
    1,430 on at

    Hey @Anonymous

     

     

    Maybe this could solve your problem to populate the dropdown.

    So you have a selected item from your gallery and want to fill in a value from the dropdown that is linked to the selected item right.

     

    So what you could do is this:

    First(Search(<DataSource>,<GalleryName>.Selected.<Field>.[Text],"<Field>")).<Field>

    The .Text is optional if it is already a text field.

     

    Hope this helps 

     

    Kind regards

     

     

    Tom

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I can't seem to even get the search function working. It keeps saying that I'm using invalid arguments but as per the documentation I'm supplying a table, search query, and column. Here's a screenshot of my windowimage.png

     

    I'm not sure how much it's worth troubleshooting as for the time being I have stopped using the lookup column due to it not being supported for delegation.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-yamao-msft

    Yes to all of your questions. That is exactly what I'd like to do.

  • AndyPennell Profile Picture
    Microsoft Employee on at

    You need to remove the quotes around Location Number. It needs a column name ie LocationNumber

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @AndyPennell

    Still no good. Also according to this page "Filter, Search, and LookUp functions in PowerApps"  the 3rd argument in Search should be used like so: 

    • Column(s) - Required. The names of columns within Table to search. Columns to search must contain text. Column names must be strings and enclosed in double quotes. However, the column names must be static and cannot be calculated with a formula. If SearchString is found within the data of any of these columns as a partial match, the full record will be returned.

    Also note that the "Center Number" field is the same as "LocationNumber". I added it in there to get the app to work properly. It's just a regular number column and not a lookup.

    image.png

  • camel Profile Picture
    Microsoft Employee on at

    This is definitely NOT the best approach to do, but I created a object with values needed on the LookUp object to be added to form.

     

    The default property looks like this:

     

    {
        '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
        Id : <id_from_the_item_in_the_lookupfield>;
        Value: <value_you_want_to_show>
    }

  • Tom_Slosse Profile Picture
    1,430 on at

    Hey @Anonymous

     

     

    If you use First(Search(...))

    You need to put a field after the bracket from the function First like this

     

    First(Search(TBL_Locations,Gallery.Selected, "LocationNumber")).LocationNumber

     

    Kind regards

     

     

    Tom

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I'm having the same problem, and I tried your suggested solution @Tom_Slosse. And while I managed to get the dropdown to successfully show item I want as a default, I receive an error upon submitting the form:

    "The requested operation is invalid. Server Response: A value must be provided for item".

    A quick search for the problem didn't give a lot of info, besides the problem arising for someone using a people field (which behaves the same way due to it also being a sort of lookup). I was wondering how you managed to get this solution without running into the same issue I did? Are there any other steps besides setting the default value? Do you combine this with another method of saving the data besides SubmitForm()? Like Patch for example, which I have seen referenced sometimes, but haven't tried using myself yet.


    Second question to @camel:
    I've tried your solution as well, adding the bracketed odata-thingy as the Default property of the dropdown connected to the SharePoint Lookup field. But contrary to the above solution, this gives me the following error:

    "The requested operation is invalid. Server Response: Value cannot be null. Parameter name: source"

    So the same applies here. The default value I want is set successfully, but I can't submit the form. Any ideas?

  • sfishe Profile Picture
    77 on at

    Can we get an update from devs on this issue please?

     

    I have the same problem: essentially, how to set a Lookup value in a dropbox listbox control, when creating a child in a parent-child relationship. This is using Sharepoint lists with lookup columns.

     

    In my case I'm selecting the related record in a gallery, then adding a new child record, using a button to navigate to another screen with an edit form. While PowerApps figures out the possible Lookup relationships fine (i.e. populates the dropdown list), having to manually select the parent (i.e. the Lookup value) is incredibly tedious and redundant when the parent is already selected on the first screen.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard