cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
5by5carnivora
Frequent Visitor

Combobox Default Selected Items Lookup Field

Hey all, 

 

I have two CDS Entities:

 

Entity 1 is called 'Bins' and the primary field for that entity is 'Barcode_no'. So, each item in that list has a barcode number.

 

Entity 2 is called 'Shipment', it has a lookup field to 'Bins' where you can select multiple bins as being part of that shipment. 

So at this point, you are likely thinking : 'OK, so in the PowerApp, when the user is entering a new Shipment this will show up as a dropdown, and the user could select the multiple bins that are part of that shipment'

But of course, it get's a bit more complicated!

 

We do not want the user to select from a dropdown, we want the user to use the barcode scanner to physically scan each bin that is part of that shipment and then the app will check to make sure those numbers exist in the bin list and selects them automatically in the back-end. 


On the 'New Shipment' Screen, I created a collection that shows the barcode of the bins as they are scanned.

I'm unsure of the best way to go about having the app take that barcode data for each bin and patch to the multi-select lookup field.  I need to either:

 

A) Use a form in the app (which I'd prefer, though I'm flexible), update the lookup field's 'default selected items' with multiple items from the collection as they are scanned

 

Or

 

B) Patch the collection to the multi-select lookup field

 

Would be grateful if someone could give me a hand with this.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @5by5carnivora ,

Do you add a Multiple-Select LookUp field in your CDS Entity?

Do you want to populate the LookUp field with multiple scanned 'Bins' with barcode value?

 

Based on the scenario that you mentioned, I think you have some misunderstanding with the LookUp field in CDS Entity. The LooUp field is essentially a Many-to-One relationship in CDS.

If you define a LookUp field in your 'Shipment' Entity, which reference Record value from your 'Bins'  Entity, the LookUp field could only reference single one record value from your 'Bins'  Entity rather than multiple ones.

Please check the following article for more details:

https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/types-of-fields#different-types...

 

# For your A direction, please set the DefaultSelectedItems property of the LookUp field ComboBox in your Edit form to follownig:

LookUp(Bins, Barcode_no = BarcodeScanner1.Value)

 

# For your B direction, please consider try the following Patch formula to submit new entry back to your 'Shipment' Entity:

Patch(
      Shipment,
      Defaults(Shipment),
      {
         LookUpField: LookUp(Bins, Barcode_no = BarcodeScanner1.Value)
      }
)

 

Of course, if you want to patch each row in your Collection table as separated new entry in your 'Shipment' Entity, please try the following formula:

ForAll(
       BarcodeCollection As LoopRecord,
       Patch(
              Shipment,
              Defaults(Shipment),
              {
                ...,
                LookUpField: LookUp(Bins, Barcode_no = LoopRecord.BarcodeValue),
                ...
              }
       )
)

Note: The BarcodeValue represents the column in your BarcodeCollection, which is used to store the scanned barcode value.

 

Regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @5by5carnivora ,

Do you add a Multiple-Select LookUp field in your CDS Entity?

Do you want to populate the LookUp field with multiple scanned 'Bins' with barcode value?

 

Based on the scenario that you mentioned, I think you have some misunderstanding with the LookUp field in CDS Entity. The LooUp field is essentially a Many-to-One relationship in CDS.

If you define a LookUp field in your 'Shipment' Entity, which reference Record value from your 'Bins'  Entity, the LookUp field could only reference single one record value from your 'Bins'  Entity rather than multiple ones.

Please check the following article for more details:

https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/types-of-fields#different-types...

 

# For your A direction, please set the DefaultSelectedItems property of the LookUp field ComboBox in your Edit form to follownig:

LookUp(Bins, Barcode_no = BarcodeScanner1.Value)

 

# For your B direction, please consider try the following Patch formula to submit new entry back to your 'Shipment' Entity:

Patch(
      Shipment,
      Defaults(Shipment),
      {
         LookUpField: LookUp(Bins, Barcode_no = BarcodeScanner1.Value)
      }
)

 

Of course, if you want to patch each row in your Collection table as separated new entry in your 'Shipment' Entity, please try the following formula:

ForAll(
       BarcodeCollection As LoopRecord,
       Patch(
              Shipment,
              Defaults(Shipment),
              {
                ...,
                LookUpField: LookUp(Bins, Barcode_no = LoopRecord.BarcodeValue),
                ...
              }
       )
)

Note: The BarcodeValue represents the column in your BarcodeCollection, which is used to store the scanned barcode value.

 

Regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (972)