Hello folks,
I’m trying to fetch information from two fields in a database and I want to display the two texts in one text element inside a repeater. Obviously I want the information to be for each item. However, for some reason I can’t seem to get this to work on one of my clients websites but it works on our other websites.
The code I’m using:
$w.onReady(function () {
$w('#bilarDataset').onReady(()=>{
$w("#repeater1").onItemReady(($item, itemData, index) => {
let brand = itemData.car_brand;
let model = itemData.car_model;
let title = brand + " " + model;
console.log(title);
$item('#txtTitle').text = title;
});
});
});
I’ve checked all of the field IDs and made sure they are all correct. For some reason this comes back as “undefined” even though there is information in the fields and I checked all permissions and everything to be sure it’s nothing like that.
Some background about the database: The information is fetched from a XML feed that has been converted to a CSV file (manually) and then imported to the database (also manually). Could this be the reason to why the system can’t “read” what’s in the fields?
I also tried making a filter function earlier with the same data collection that didn’t work either. Same thing there, the filter function works on other websites. I am pretty sure there is something specifically wrong with this specific data collection… I just don’t know what the problem is or how to solve it.
Anyone that has any idea what I can do to fixe this? I’d really appreciate all the help I can get.
Many thanks in advance!
/Joe
1 Like
Hello Joe.
Please share your site or site Editor URL and the name of the page with the issue so that we can take a closer look.
Awaiting your reply!
Hello Sam, Thank you for your reply.
Here is the editor link: https://editor.wix.com/html/editor/web/renderer/edit/bd12bb10-57c6-4ef7-88b0-f9568822496d?metaSiteId=de565a92-826e-4e3b-b823-f74a88d816d3&editorSessionId=d2beb60a-64bf-48cc-a948-185a3f4087b0
The data collection is on a dynamic page showing all products called “BilarGavle (All)”. Only dropdown option that’s been coded to execute the filter function is “Bilmärken” right now. The other dropdowns are not connected to anything.
Many thanks in advance!
/Joe
Hi @support70859 , you can set a reference field in your database, that way you can easily use the data in the other database.
Or you can use a query inside your repeater to fetch the relevant value.
I can’t really help further unless you provide us with more specific details.
Ok …so you’ve checked database permissions already, synced data, checked element IDs …
Have you checked field keys? What about field types?
Dataset mode?
If there is nothing wrong with the written code or the configuration … you can try recreating a new one (to determine if there is something wrong with the collection or maybe an element has a glitch). For example create a test collection with the same field types, manually add a few rows of fake or real data, create a test page, brand new repeater, new dataset (do not copy old elements), then test it. If it works … connect the dataset to the real database. And see what happens …
Hello @code-queen , Thank you for your reply!
I did look through everything, I also, to be sure, looked through the fieldKeys again, and of course… I had missed an underscore… I had “car_brand” instead of “car__brand” (it has 2 underscores). This is a silly mistake on my end. I apoligise for wasting everyones time.
Many thanks to everyone that tried to help out! I really appreciate your help!
Best regards,
Joe