Hi, I need to compare the dataset2 items with the repeater items. Repeater is connected with the dataset1.
I've a field name "firm" in dataset2. Repeater is getting firm name from dataset1. I want to choose the interest rate according to firm stored in dataset 2. I don't know how I should sync or compare this. Also, this can be possible with the reference field but I'm unable to get it even I read the wix document related to this.
wixData.query("transfirm").eq("_owner", wixUsers.currentUser.id).eq("name", $item('#text43').value)
.find()
.then( (results) => {
let resultQuery = results.items.length;
console.log(resultQuery);
Here I try to compare the field value with the current item. So, length should be one but it showing two. Means the second condition is not working. Help Me!
@Yisrael (Wix) Hi, Thanks for the solution again. I was enjoying holidays after solution and now again a problem occurs. For the solution code, I'm getting these results.
let queryItems = results.items; queryItems.forEach((item, idx)=>{ for(idx =0; idx <= queryItems.length; idx++){ if($item('#text18').text === item.name){ $item('#text43').text = item.rateofinterest; //console.log("Here is the rate" + item.rateofinterest); var rate =parseFloat($item('#text43').text); console.log(rate); } }
Please realize that that is a lot of code to look through. I would suggest adding some console.log() statements to see what's happening in the onItemReady() function.
One minor thing I noticed is that the onItemReady() function should not be inside the dataset onReady() function.
And please post your code, nicely formatted, in a code block. Do this:
Maybe you have two records in the db collection that meet the criteria?
Where are you using this code? You will need to show context. What does the repeater look like?