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

Multi select CDS lookup field on edit form only retaining one value when submitted

I have an edit form showing records selected from a gallery. One of the edit form fields is a lookup field with selectmultiple set to 'true'. The field is also filtering lookup values based on a combo box selection, this works fine. 

 

Filter(Benefits,'Associated Project'.'Project Name'= ProjectSelectionComboBox.Selected.'Project Name')

 

When a user selects more than one value from this field, and submits the form, only one value is retained\saved. Even after refreshing data sources and reopening the edit form, it only ever shows one value.

 

I simply cannot figure this out....

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @RMcQueen ,

No, you do not need to create another entity to relate multiple benefits to a single milestone.

Since you have create a N:N relationship between benefits entity and milestone entity, then you could use Relate function to relate multiple benefits to a single milestone or relate multiple milestones to a single benefit.

This kind of relationship will not reflect by a lookup field.

You could directly filter milestone entity based on benefits entity, or filter benefits  entity based on milestone entity, no need to use lookup field.

 

1)How to relate multiple benefits to a single milestone or relate multiple milestones to a single benefit?

In powerapps, use formula like this:

Relate( Entity1RelatedTable, Entity2Record )

For example, set one combo box's Items to benefits entity, set one gallery's Items to milestone entity.

Then use this formula to relate multiple benefits to a single milestone:

Relate(benefitscombobox.SelectedItems,milestonegallery.Selected)

 Then you will relate all the selected items of benefits in that combo box to the selected item of  milestone in the gallery.

2)How to filter benefits entity based on an item in milestone entity?

For example: insert a gallery to display benefits entity, set one gallery's Items to milestone entity.

set gallery1's Items:

milestone

set gallery2's Items:

milestone.Selected.benefits

 Then gallery2 will display related items in benefits entity based on selected item in milestone entity.

 

The doc that I provided has described this detailed, please refer:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-relate-unrelate

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

9 REPLIES 9
GarryPope
Impactful Individual
Impactful Individual

Hello @RMcQueen.

I hope you're well. I'm being a bit thick here, and can't exactly work out what you're doing, sorry. You say, "When a user selects more than one value from this field", what value are they selecting, another record from another entity?

If so, what is the relationship between the two entities please?

Thanks very much,

Garry

v-yutliu-msft
Community Support
Community Support

Hi @RMcQueen ,

Could you tell me:

1)which entity does the lookup field looks up to ?

2)ProjectSelectionComboBox's Items?

3)the relationship between these two combo boxes?

Only showing me the formula is not enough. Please describe the details.

4)this lookup field datacard's Update?

Since you want to update with multiple selections, please set the datacard's Update like this:

combobox.SelectedItems

If you use "combobox.Selected", then that's the reason why you met this problem, because "selected" represent the first one selection, not all the selections.

 

 

Best regards,

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

@GarryPope  Yeah there are 3 entities in play here; Projects, Milestones and Benefits.

 

Project to Milestone 1:N

Project to Benefit 1:N

Milestone to Benefit N:N

 

I have a gallery displaying milestones related to the project selected in a stand along combo box. An edit form displays details of the milestone selected in the gallery. The edit form contains a field which looks up the benefits. The field is filtered to only show benefits related to the project selected in aforementioned combo box and is also set to multiselect. 

 

I want users to have the ability to add multiple benefits against a milestone any time. The edit form allows for multiple values to be selected in the field, but when submitting the form only one is saved.

Before submitting the form
Before.JPG

After submitting the form
After.JPG

Default on the data card is set to ThisItem.'Associated Benefit'

 

Update on the data card is set to DataCardValue17.Selected (entering SelectedItems presents red lines of doom)

DefaultSelectedItems on the data card's lookup combo box is set to ThisItem.'Associated Benefit'

 

I hope this additional information clarifies the situation more.

Hi @RMcQueen ,

Do you mean that:
1)the field is a lookup field in  milestones entity?

2)you want to update this field with multiple selections?

Please notice that:

 all custom lookups can only allow for a reference to a single record for a single target record type.

This means that one lookup field could only refer to one record, not allows multiple value.

I suggest you know more about lookup field here:

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

 

That's the reason why you could only set the datacard's Update to DataCardValue17.Selected instead of "SelectedItems".

"Selected" represents one selected record. "SelectedItems" represents all selected records.

 

If you want to reflect the N:N relationship between Milestone to Benefit, please do not use lookup field.

There's no lookup field between N:N relationship.

We usually use Relate function to reflect relationship between N:N relationship.

I suggest you know more about this function:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-relate-unrelate

 

 

Best regards,

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

@v-yutliu-msft  - yes the field is a lookup to benefits within in the milestone entitiy and, yes, I'd to update this field with multiple benefits. 

 

I guess the only way for the users to link multiple benefits to a single milestone will be to add additional fields to the milestone entity which also look up the benefits entity and name them something like 'Associated Benefit 2', 'Associated Benefit 3' etc etc....? 

 

 

Your best approach would be to follow @v-yutliu-msft advice and create an N:N relationship between Milestone and Benefit and use one of the N:N PCF components found at PCF.gallery such as NN Tags to display the selected options.

 

 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Hi @RMcQueen ,

No, you do not need to create another entity to relate multiple benefits to a single milestone.

Since you have create a N:N relationship between benefits entity and milestone entity, then you could use Relate function to relate multiple benefits to a single milestone or relate multiple milestones to a single benefit.

This kind of relationship will not reflect by a lookup field.

You could directly filter milestone entity based on benefits entity, or filter benefits  entity based on milestone entity, no need to use lookup field.

 

1)How to relate multiple benefits to a single milestone or relate multiple milestones to a single benefit?

In powerapps, use formula like this:

Relate( Entity1RelatedTable, Entity2Record )

For example, set one combo box's Items to benefits entity, set one gallery's Items to milestone entity.

Then use this formula to relate multiple benefits to a single milestone:

Relate(benefitscombobox.SelectedItems,milestonegallery.Selected)

 Then you will relate all the selected items of benefits in that combo box to the selected item of  milestone in the gallery.

2)How to filter benefits entity based on an item in milestone entity?

For example: insert a gallery to display benefits entity, set one gallery's Items to milestone entity.

set gallery1's Items:

milestone

set gallery2's Items:

milestone.Selected.benefits

 Then gallery2 will display related items in benefits entity based on selected item in milestone entity.

 

The doc that I provided has described this detailed, please refer:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-relate-unrelate

 

 

Best regards,

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

Hello @RMcQueen,

I hope all is well. Seems like you got some great advice already, so I hope this has solved your problem.

Reply if you're still having trouble.

Thanks very much,

Garry 

FacundoGorla
Helper V
Helper V

I have the N:N relationship but when I try to edit the main Form of any of the two tables I can't add the field in the form, how am I suppose to select wich rows are related? I'm not using a canvas app I'm using a model driven one

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (3,338)