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 / Pre-populating a looku...
Power Apps
Answered

Pre-populating a lookup field

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have two forms & data sources (both SharePoint) within my app and I need to create a link between the two, ideally populating a lookup field in my second form so the user doesn't have to search for it. DataSource1 = "Projects". DataSource2 = "DataSet". The user navigates from the Projects form to the DataSet form, but there is also a button from the home page where they can go direct to DataSet, with no linkage required.

 

So "Data" has a lookup to "Projects" based on a field "ProjectName".  Items for this field is set to: Choices([@DataSet].LinkedProjects).

 

I've played with different options, including this one:

 PATCH A SharePoint LookUp Column In Power Apps - Matthew Devaney. However, I get an error with this saying it was looking for a table and I had a record. I tried it to include the below, but no luck with this either.

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",

I set a global variable on one of the Projects forms to grab ProjectName.

I've tried setting the default of the field to this variable but it doesn't populate. 

Another option was set the default to lookup the Author.Claims of the Projects list with that of my 'loggedUserClaims' another variable. Again, it doesn't populate.

 

Is there something I've missed, or is there anything else I could try? 

Categories:
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Since your field is a lookup field you will need to do something like this:

     

    Filter(DataSet.LinkedProjects, ColumnName in globalvariable)

     

    This assumes that your globalvariable is a text field and not a record value.

     

     

     

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @JR-BejeweledOne , thanks for your response.

    Yes my global variable is a text field and not a record value. Should column name be 'LinkedProjects'? I've tried this but I get an error: Invalid argument type. Cannot use Table values in this context. Expected Record value.

  • Verified answer
    JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I am doing something similar.   Here is how I do it.  

     

    Rather than having the items in my multi-select dropdown pull directly from my data source, it's set to a single column collection.

     

    The collection is created based on the value of another dropdown.   Then I am able to use the formula that I showed you to preset that field if an item in my gallery is selected.

     

    So my DefaultSelectedItems is this:

     

    Filter(RegionsColl, Region in varRegion)

     

    I struggle with the whole table vs record value thing too.    This is how I resolved it in this case.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @JR-BejeweledOne  that worked for me. I set Items to the collection and DefaultSelectedItems to your formula above. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @JR-BejeweledOne Did you have any issues saving this value back to your data source? I'm getting a server error: bad gateway which I've seen before with lookup fields.

    Update property of the data card is {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: -1,
    Value: DataCardValue31.Selected
    }

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    In my app I am not saving it back to a lookup field.   My lookup field comes from a different table.   The table I am saving my data back to is mostly text fields.  I concat the values from the multi-select to save into the text field.

     

    I find it much easier to do it that way.  

     

    And if the record needs to be edited, I can set my combobox to the value of the text field.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @JR-BejeweledOne I figured out I needed to add my combobox to a text field which works fine except when more than one selection is made. Could you tell me how you concat the values so they all save back?

    Do you then have a way of updating your lookup field?

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    This is out of my patch statement:

    Region: Concat(ComboBoxRegion.SelectedItems.Region, Region & "; ")

     

    For the edit, when the record is selected in the Gallery, I set a variable (Set(varRecord, ThisItem) and an edit flag variable.  This gives me all the record information and makes it easy to work with.

     

    This is my DefaultSelectedItems property for the combobox (Note.  On the change of my country dropdown, I am collecting the associated regions into a collection and I use the regions collection in my combobox)

     

    If(

    !NewItem && EditItem, Filter(RegionsColl, Region in varRecord.Region),
    CheckboxAllRegions.Checked, RegionsColl
    )

     

     

    Hope this helps

  • premankur_s Profile Picture
    13 on at

    Hi , it is showing delegation warning

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard