Hi guys I’ve just tried to set random numbers to my database especially a field.
For example I want to set random numbers for my ads.
export function kontrol($item, itemData, index) {
$w("#repeater1").onItemReady( ($w, itemData, index) => {
if( itemData.ilanNumarasi!="") {
console.log("Boş")
itemData.ilanNumarasi=(Math.random()*(1000+1)).toString()
}
else {
console.log("Dolu")
}
But it didn’t set anything. 
You need to set on the element itself, not on the data that comes from the dataset.
export function kontrol() {
$w('#repeater1').onItemReady(($item, itemData, index) => {
if (itemData.ilanNumarasi !== '') {
console.log('Boş')
$item('#ilanNumarasi').text = String(Math.random() * (1000 + 1))
console.log('Dolu')
}
})
}
That worked mate thx. Now I’m trying to save this numbers to my database items.
export function kontrol() {
$w("#dataset1").onReady(() => {
$w('#repeater1').onItemReady(($item, itemData, index) => {
if (itemData.ilanNumarasi !== '') {
console.log('Boş')
var ilanNo = String(parseInt(Math.random() * (1000 + 1)))
$item("#text50").text = ilanNo;
}
$w("#dataset1").setFieldValue('ilanNumarasi', ilanNo)
})
})
$w("#dataset1").save();
}
@loeix Do you have any idea mate?
@kusadasiticaret When do you want to save it? Because the code logic is a little bit off… Does the user have to click somewhere?