Display Reference Fields That References Items in its Own Collection

I have a dynamic page that displays item information from the dataset. This dataset has a few multiple reference fields that link to variations within the same dataset.

I looked at the documentation and according to the instructions a secondary indented field is supposed to pop up asking what information I want to connect field.

My issue is that the referenced fields don’t even show up in the list in the first place. I can’t connect these fields to ANYTHING.

What could the issue be? Everything is “published”.

I have tried connecting to a repeater and a table. The reference field does not show up in the list at all, even greyed out.

I too had a similar situation in my hand just few days ago. I too couldn’t understand the situation however I started again from the scratch by adding new data set and editing the reference field and miraculously it worked. Maybe it was some kind of glitch.

It wont even let me delete the dataset from the dynamic item page… XD

Then I think so you should create whole new dynamic page through the collection of that data set
Maybe similar to this

So I contacted Wix about this issue, as nothing was working for me. I even tried re-creating the page as per Shishir’s suggestion.

Apparently, you cannot display a reference field that is in the same dataset you are using.

For example, I have Dataset A with an Item A and an Item B.

Item A is a variation of Item B, so I create a multi-reference field titled “Variations” and reference Item B in the Item A record.

All of this is in the dame dataset, so you cannot display that Variation field at all.

Which sucks, because now…well, I’m screwed.

If anyone knows a workaround that does not require making another dataset, let me know. I am crying over here. :disappointed_relieved:

Can you show the format of the database? and what the reference fields look like? You might have to write some custom code but you should be able to query the database and just return values that match a specific condition.

I am not sure what you mean by format. The dataset has the item name, the company, measurements, photos, etc. Typical dataset stuff, I guess. The item name is the primary field.

The multi-reference fields (aka my Variations field that I want to display on the dynamic page) just have items from the database. It looks like a typical reference field as it does in the tutorials.

Tutorial image:

I thought about the query thing, but I am not sure how it would work. There are too many variables.

I am trying to display all variations of the item that is being viewed on the dynamic page. For example, there are about 10 variations of the item “Violet” by the same company. However, simply using a filter to display items with the name “Violet” will not work as there may be other items with the same name but different companies and/or the name of the variation may not be exactly the same or titled something entirely different.

If you are filtering based off a dynamic Item page then the page has context to the specific database field that it correlates to. So it should have all the information necessary to display the information that you want it to. You can see the item it’s self with the following code:

$w.onReady(async function() {
    $w("#yourDatasetName").onReady(async() => {
        let item = $w("#yourDatasetName").getCurrentItem()
        console.log("dataset item",item)
    })
})

If that contains the information that you are looking for then you should be able to render it to the screen, but I still don’t know how you want to display this information (dropdown, text element, buttons, etc)

I would like to display it in repeaters. An image, item name, and company name, for example.

That will be very technical. I was under the impression that this is based off an existing repeater item. If that is the case then you would have to create a new repeater for every repeater element with code, then map through the color variations and add each one to the new custom repeater. You would also have to do this inside the .onItemReady function of the existing repeater so that each repeater element would have a new repeater that correlates to the color variations for that specific item.
Something like this:

$w("#nameOfYourExistingDataset").onReady(() => {
        $w("#nameOfYourExistingRepeater").onItemReady((item, itemData) => {
        const mappedData = itemData.map(item => {
                return {
                        "itemName": item,
                        image: itemData.image,
                        company: itemData.company
                }
        })
       $item("#newRepeater").data = mappedData
       $w("#newRepeater).onItemReady((item, itemData) => {
       $item("#name").text = itemData.itemName,
       $item("#image).src = itemData.image,
       $item("#company").text = itemData.company
       }) 
    })
})

Now keep in mind this is just a BASIC implementation of something that MIGHT work for you. I know it is not intentional but your answers and replies are very vague so I have literally no idea what the format of your database is. I have no idea how the information that is being accessed is being stored on that database. I have no idea if you even have a repeater to begin with.

All that being said you will likely have to adapt this code to work for you. If you are completely lost then I will be unable to provide more help from here. Wix does have an option for you to hire a developer if you are completely stuck. They should be able to assist further.

I hope this helps.

Note: Apparently, you cannot display a reference field that is in the same dataset you are using. HOWEVER, there is a workaround! Keep reading!

I have found a solution to this problem. There is no code needed at all. Here is how it’s done. Anything highlighted in orange will be the name of your dataset. I have used the word “Products” as an example.

  1. Create the dynamic item page. This automatically adds the item dataset to the page.

  2. Add a repeater to that dynamic item page.

  3. On the repeater, click the “connect data set” squiggle icon.

  4. In the connect to dataset drop-down menu click the “create a new dataset”.

  5. Choose the main dataset that contains the items from the dynamic page. For example, the dynamic page dataset is called " Products Item". You need to add the main dataset " Products ".

  6. Next, click on the little dataset icon " Products " and select “Settings”.

  7. Make sure that the dataset is set to “Read & Write”.

  8. Scroll down a little and select “Add Filter”.

  9. In the “Field” section select the reference or multireference field you want to display.

  10. Select “Includes” for the condition.

  11. Under the “Dataset” section find the dataset " Products Item" MAKE SURE IT POINTS TO THE “ITEM” DATABASE SET, not the main database set.

  12. Be sure to click “Save”.

  13. Connect each individual repeater item like usual. If you want to link to the item you are displaying, make sure the “Link connects to” is pointed at the " Products (Items)" dataset.

You can repeat this process if you want to display more than one reference field on your dynamic item page. Just remember to rename the duplicate dataset to something else for easier reference. In my situation, I had three datasets on my page.

Products Item
Products Variation 1 (filtered to a multi-reference field)
Products Variation 2 (filtered to a different multireference field)

Products Variation 1 & 2 are the exact same datasets and are the exact same collection, but each one has a different filter applied and each one is connected to a different repeater.

I did run into a problem where the image in the repeater did not want to update and displayed the same image in every item. I simply deleted the repeater and connected everything again and it fixed itself.