You can now add multiple items to Reference Field Type

Introducing the feature you’ve been all waiting since you tried Reference Field Type – ability to add multiple items from referenced collection.

Be aware that if you decide to update your current Reference field type to allow multiple items, your previously added items would not be preserved, so make sure you backup your data or start with creating a new field.

There’re also some changes in how you should connect your data when working with Multiple Item Reference field in Editor. Unlike Reference field type in Single Item mode, you won’t be able to connect this field type directly to components. Instead, you need to rely on Dataset. Whenever you want to show Movies and their Actors, just add 2 datasets – one for movies and one for actors – and then apply a Filter by Dataset.

Might sound confusing at first, but once you go over this article, you’ll be an expert: .

Also, some more details of how Reference field in this new Multiple Item mode works can be found here: .

Some multiple item reference API:
hasSome() (aka includes some of)

Last but not least, we would really appreciate if you give us some feedback on this feature by filling in this anonymous 4-question form .

The Google Form has a permission error :slight_smile:

Solved. :slight_smile:


Quick Question for you in code:
I want to use setFilter in code for multiple items like this…

$w(“#dataset2”).setFilter( wixData.filter()
.contains(“DemoCategories”, “name of category clicked”)

I have two repeaters, one with buttons as categories and one with products. When I click the button I want to use the includes that you have as a filter between Datasets but in code. Possible?

זה מעולה! אבל צריך להשים לב שבעבר זה גם היה אפשר רק מגדירים את השדה במסד נתונים על url כעת, כל מי שהשתמש בזה בעבר הופך לו לשגיאה!

We’ll publish multiple-item-reference-specific API on Monday.

Currently, you can achieve that without code, if you use table and repeater, as selected row in table changes the current item in the dataset. Alternatively, you can change current item on category dataset, and filter on another dataset will give you filtered data.


Strange thing but the function $w(“#dataset1”).setCurrentItemIndex(1); does not trigger within the loop in the repeater.

I’m having some trouble with updating the field

That error can sometimes occur when working with Data Collections. Just keep on trying and it will probably go away soon.

Looks promising. I could have used this a months ago. Instead, I developed it as 1-n relationships, (1 main row, n detail rows with 1 ref per row to master), forcing me (for result viewing) to also write my own Left Outer Join, wrap it in a array of objects and hand that to a repeater.
One question: did you envision some kind of error handling for the case where Master row holds ref A, B, C and D to detail, but Details has no C (or any other of the 4), in short, inconsistency?

Is there any way to sort multiple items in a repeater simply by the order they were added in? If I’m adding multiple items to a dataset - like apple, orange, banana - chances are that I want them to appear in that order. And that is apparently not only NOT the default behavior, but completely impossible aside from javascript gymnastics.

@giri, that was the workaround to have multiple references. And you shouldn’t worry about that kind of error situation, Details will always contain A, B, C and D and will always be consistent.

@tandrewnichols, the order of added items in the cell is based on the timestamp when the item is inserted. As each of the insert happens async, there’s a chance that if you quickly insert multiple items, there might happen some inconsistencies. On the other hand, when you use a Dataset to show the items from referenced collection, you can not only use Include/Exclude field on multiple item reference field, but also add additional filters to show items for example alphabetically.

@Andreas, checkout API for this type of field, updated original post.

the order of added items in the cell is based on the timestamp when the item is inserted

@adas-bradauskas Are you referring to the date created in the reference table or is there a separate timestamp for when it’s added as a reference ?

For example, if I add “apple” and then “banana” to the fruits dataset, and then in another data set with a “fruits” reference field add “banana” and then “apple” . . . what order will they be displayed in and is there a way to force them to be displayed as “banana” then “apple”?

Incidentally, I’m currently trying to do this by including them in the query results with


(using the same example), but that’s actually throwing an error.

Specifically, with this error:

Error is on newIncludedFields.push. I can fix it if I set

query.included = [];

first. I’m guessing that value just isn’t initialized correctly.

@tandrewnichols, order is based on when items are added to referenced table. So in your example, when you have multiple item reference field for “Fruits”, you should see “banana” and then “apples”.

Keep in mind that working with multiple item reference field, you’d better of using specific API, so in case to get those items you should use queryReferenced() .

Thank you. I was not aware of queryReferenced.

I started in with a cheer…but then pulled up with a whoa! Not finding how to get the multiple items to show up in field. Not sure how the sorting you are using is accomplishing this.

So a bit confused on using the filter to get around this as you describe…more explanation is needed on this (here and on the wix page ). Not sure how this accomplishes the task…maybe no need to understand, but without that I can not visualize how to make this jump to multiple item reference.

I am just wanting one column to appear right now, pulling from one dataset…will get that understood and then tackle more. So in your case, I just want to show a list of the actors that I have “listed” in the multiple-item reference field.
Have tried using filters as noted and does not work at all…will not allow you connect a table to a multiple-item table no matter what filtering you use. Something not right with the examples given. Missing a step here and on wix page).

And in reading back through your explanation, I believe it should be reworded. It makes it sound like you can use a filter to accomplish goal of connecting a multiple-item reference to a table. You can not. Your point was to tell folks to use the old way of connecting data (i believe).

So this begs the question…what good is the multiple-item reference field when you can not connect it to anything?

Where am I going wrong. Referencing field to its own database (allowed for single-item references). But not getting anywhere with trying to get multiple-item to work

So what is the purpose of the multiple item reference field in Wix’s eyes? It seems a decision has to be made of using or not using if building a database, otherwise if you change, you have to completely rebuild the database. What features are in the works, because as I see it, currently it has no use as you can not connect a multi-ref to any items…there is only work around of using the “old”, single-ref fields using a dataset sort. So what has been gained?