Hi everyone,
I created a script to update some values on a collection so that they have currency format, however when running the script it skips some of the items, any idea why?
P.S. I have tried doing it by adding a limit of 50 and the first query works fine, but after that and skipping to the next 50 it starts to skip items.
Here is the script:
export function button17_click(event) {
//perform();
$w("#gif").show();
updatetotals();
}
async function updatetotals() {
const result = await wixData.query("InvoiceHolding").skip(0).limit(50).find();
result.items.forEach(async function (item) {
item.totalformato = formatoprecio(item.total);
item.pagoformato = formatoprecio(item.pago);
await wixData.update("InvoiceHolding", item)
});
$w("#gif").hide();
$w("#table1").refresh();
}
function formatoprecio(x) {
var number = Number(x);
return '$' + number.toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
}
Any ideas?