I realized that I have two different custom update forms with dropdown lists that has resulted in two different formats for a database field. I have implemented the following code to loop thru the database and update the mal-formed field:
import wixData from ‘wix-data’ ;
$w.onReady( function () {
})
export function updateAll_click(event) {
console.log( “Beginning Update…\n\n\n” )
async function loopThrough()
{
let count = $w( “#dataset6” ).getTotalCount();
console.log( "Total Count = " , count)
var results = await $w( “#dataset6” ).getItems( 0 , count);
for ( let i= 0 ; i < count ; i++) {
var payInfo = results.items[i].payment_info;
var itemID=results.items[i].itemID;
console.log( "Payment Method: " , payInfo)
// There are varying differences in the database for paypal payment method… will need to fix all update forms…
if (payInfo === “PayPal - $50” ) {
let newInfo = “PayPal : $50” ;
await updateItem(newInfo, itemID);
}
if (payInfo === “PayPal $50” ) {
let newInfo = “PayPal : $50” ;
await updateItem(newInfo, itemID);
}
if (payInfo === “PayPal - $100” ) {
let newInfo = “PayPal : $100” ;
await updateItem(newInfo, itemID);
}
if (payInfo === “PayPal $100” ) {
let newInfo = “PayPal : $100” ;
await updateItem(newInfo, itemID);
} }
}
async function updateItem(newInfo, itemID)
{
var results= await wixData.query( “Items” )
.eq( “_id” , itemID)
.find()
if (results.items.length > 0 ) {
let item = results.items[ 0 ];
item.payment_info=newInfo;
console.log(item);
await wixData.update( “Items” , item);
}
}}
========================================================
When running in Preview mode using Sandbox database it gives following errors in Java Console…
Any assistance is greatly appreciated…
Thanks
JD