cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

save multiple items from a combobox in sharepoint

Hello,

I have a form on powerapps that fills the data on a sharepoint list.

There are many comboxes in the form, I would like to save several items of a combobox (DataCardValue2) in the sharepoint list.

Is it possible to put these records one after the other instead of grouping the items in a single field.

I built this code but it does not work.
Can you help me ?

thank you.

 

Spoiler

ForAll(
DataCardValue2.SelectedItems.Value;
Patch(list_spo; Defaults(list_spo);

{
Date_x0020_d_x0027_intervention:DataCardValue4.SelectedDate;
Activit_x00e9_:DataCardValue1.Selected.Value;
Temps_x0020_en_x0020_minutes:DataCardValue5.Selected.value;
Type_x0020_de_x0020_personnel:DataCardValue11.Selected.Value;
Cr_x00e9_neaux_x0020_horaires:DataCardValue10.Selected.Value;
R_x00e9_sidents:DataCardValue2.Selected.Value;
}
)
)

6 REPLIES 6
Highlighted
Super User
Super User

Re: save multiple items from a combobox in sharepoint

@Edvh 

A ComboBox with multiple selections must be referenced using SelectedItems..  Suggest you try changing this line of code

R_x00e9_sidents:DataCardValue2.Selected.Value;

 

To this code and see if it works.

R_x00e9_sidents:DataCardValue2.SelectedItems;

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Helper II
Helper II

Re: save multiple items from a combobox in sharepoint

hi @mdevaney 

thank you for your help,

I tried your solution but it does not work.

 

Spoiler

ForAll(
DataCardValue2.SelectedItems.Value;

Patch (Saisie_heures;
Defaults(Saisie_heures);
{
Date_x0020_d_x0027_intervention: DataCardValue4.SelectedDate;
Activit_x00e9_: DataCardValue1.Selected.Value;
Temps_x0020_fr_x0020_minutes: DataCardValue5.Selected.value;
Type_x0020_de_x0020_personnel: DataCardValue11.Selected.Value;
Cr_x00e9_neaux_x0020_horaires: DataCardValue10.Selected.Value;
R_x00e9_sidents: DataCardValue2.SelectedItems;
}
)
)

 

Highlighted
Community Support
Community Support

Re: save multiple items from a combobox in sharepoint

Hi @Edvh ,

 

Would you please tell how would you like to put these records one after the other? Did you mean that you want to create multiple items with only this field different and other fields have the same value? What is the column type and setting for this field? Normally, if the column is multiple select enabled choice field, it will show as a combo box inside form control.

 

For example, if you have selected multiple choices in the combo box control, to patch the first choice for the 1st item and second choice for the 2nd item, the formula should be:

Patch (Saisie_heures;
Defaults(Saisie_heures);
{
Date_x0020_d_x0027_intervention: DataCardValue4.SelectedDate;
Activit_x00e9_: DataCardValue1.Selected.Value;
Temps_x0020_fr_x0020_minutes: DataCardValue5.Selected.value;
Type_x0020_de_x0020_personnel: DataCardValue11.Selected.Value;
Cr_x00e9_neaux_x0020_horaires: DataCardValue10.Selected.Value;
R_x00e9_sidents: First(DataCardValue2.SelectedItems)
}
);
Patch (Saisie_heures;
Defaults(Saisie_heures);
{
Date_x0020_d_x0027_intervention: DataCardValue4.SelectedDate;
Activit_x00e9_: DataCardValue1.Selected.Value;
Temps_x0020_fr_x0020_minutes: DataCardValue5.Selected.value;
Type_x0020_de_x0020_personnel: DataCardValue11.Selected.Value;
Cr_x00e9_neaux_x0020_horaires: DataCardValue10.Selected.Value;
R_x00e9_sidents: Last(FirstN(DataCardValue2.SelectedItems,2))
}
)

 

You need to set the Patch formula one by one. And this only works if you know how many choices there are being selected.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

Re: save multiple items from a combobox in sharepoint

hi @v-monli-msft 

 

I would like to select several residents. (DataCardValue2) and when I validate the records are done one after the other in my sharepoint list.

 

What I want above all is to make several recordings of the combobox DataCardValue2.

In Sharepoint the resident column is defined as "search" from another sharepoint list. It will appear as a drop-down list in the form control.

 

I tried your code but unfortunately I have an error.

Highlighted
Helper II
Helper II

Re: save multiple items from a combobox in sharepoint

hi @v-monli-msft 

 

I tested the solution but I can only save two items. even if I change the value 2 by N record.

The difficulty is that the resident field is a lookup type column in my SH list.

I want to save only several values ​​in this field. Do not you think it will be necessary to call the

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

otherwise I thought about creating a resident collection.

 

Then in my form I will create a resident field using the collection and save the values ​​in a text column in sharepoint, what do you think?

Spoiler
with this code I have N lines which is registered but I always have the same value on the resident column.

ForAll(
DataCardValue2.SelectedItems;
Patch(
Saisie_heures;
Defaults(Saisie_heures);
{
Dateintervention: DataCardValue4.SelectedDate;
Activit_x00e9_: DataCardValue1.Selected;
Tempsenminutes: DataCardValue5.Text;
cr_x00e9_neauxhoraire: DataCardValue10.Selected;
Typedepersonnel: DataCardValue11.Selected;
R_x00e9_sidents: DataCardValue2.Selected
} ))


column type in sharepoint :


Dateintervention:  Date;
Activit_x00e9_: Choices;
Tempsenminutes: single Text;
cr_x00e9_neauxhoraire: Choices ;
Typedepersonnel: Choices ;
R_x00e9_sidents: Lookup

 when I put R_x00e9_sidents: DataCardValue2.SelectedItems;

I have the following error: the type of this argument does not match the expected type "Record". Type Found "Table"

Highlighted
Helper II
Helper II

Re: save multiple items from a combobox in sharepoint

Is there someone who can help me with my problem?

 

please

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (6,493)