There seems to be something going on where a few different pages on my site are no longer able to add new records to the linked database collection. I had seen a few others post similar experiences but no resolved responses to them either just yet. I previously set up a page on our website for members to submit any volunteer hours completed so we could keep track of them. I use code to calculate the hours and minutes for a total and then have it set the values within the database field once the submit button is pressed.
Since I created the page back in January of 2019 up until February 8th of this year, it has worked perfectly. But for some reason, as of February 8th, 2021, it will no longer add any new records. The database only has a total of 623 records as of this point so there is not an extreme amount. I am not getting any errors whatsoever with the code. I am at a loss.
My code is listed below (it is long only because we have several different categories for the volunteer hours that we are tracking) but as mentioned, nothing has been changed since first added back in 2019. Though this is one example, I have a couple other records pages on our site as well that are experiencing the same thing.
import wixData from 'wix-data'; import wixLocation from 'wix-location';
export function SubmitHrs_click(event) { //Calculation parameters for time breakdown var a = '60' //Member Data Columns $w('#dataset3').setFieldValue('fullName', $w('#name').text); $w('#dataset3').setFieldValue('email', $w('#email').text); $w('#dataset3').setFieldValue('memId', $w('#memid').text); $w('#dataset3').setFieldValue('entryDate', $w('#datePicker1').value); //Year only extraction for database let yearonly = ($w('#datePicker1').value).getFullYear() $w('#dataset3').setFieldValue('year', yearonly); //Faith Activities Data Columns let faithRH = (+$w('#input1').value + +(($w('#dropdown1').value) / a)) let faithCFH = (+$w('#input2').value + +(($w('#dropdown2').value) / a)) let faithCSH = (+$w('#input3').value + +(($w('#dropdown3').value) / a)) let faithRVH = (+$w('#input4').value + +(($w('#dropdown4').value) / a)) let faithPSH = (+$w('#input5').value + +(($w('#dropdown5').value) / a)) let faithSGH = (+$w('#input6').value + +(($w('#dropdown6').value) / a)) let faithMH = (+$w('#input7').value + +(($w('#dropdown7').value) / a)) $w('#dataset3').setFieldValue('faithRsvpHrs', faithRH); $w('#dataset3').setFieldValue('faithChurFaciHrs', faithCFH); $w('#dataset3').setFieldValue('faithCathSchoHrs', faithCSH); $w('#dataset3').setFieldValue('faithReliVocaHrs', faithRVH); $w('#dataset3').setFieldValue('faithPrayStudHrs', faithPSH); $w('#dataset3').setFieldValue('faithSacrGiftHrs', faithSGH); $w('#dataset3').setFieldValue('faithMiscHrs', faithMH); //Family Activities Data Columns let familyFoFH = (+$w('#input8').value + +(($w('#dropdown8').value) / a)) let familyFFH = (+$w('#input9').value + +(($w('#dropdown9').value) / a)) let familyKCH = (+$w('#input10').value + +(($w('#dropdown10').value) / a)) let familyFWH = (+$w('#input11').value + +(($w('#dropdown11').value) / a)) let familyFPH = (+$w('#input12').value + +(($w('#dropdown12').value) / a)) let familyMH = (+$w('#input13').value + +(($w('#dropdown13').value) / a)) $w('#dataset3').setFieldValue('familyFoodFamiHrs', familyFoFH); $w('#dataset3').setFieldValue('familyFamiFormHrs', familyFFH); $w('#dataset3').setFieldValue('familyKeepChristHrs', familyKCH); $w('#dataset3').setFieldValue('familyFamiWeekHrs', familyFWH); $w('#dataset3').setFieldValue('familyFamiPrayHrs', familyFPH); $w('#dataset3').setFieldValue('familyMiscHrs', familyMH); //Community Activities Data Columns let communityCKH = (+$w('#input14').value + +(($w('#dropdown14').value) / a)) let communityGWH = (+$w('#input15').value + +(($w('#dropdown15').value) / a)) let communityHHH = (+$w('#input16').value + +(($w('#dropdown16').value) / a)) let communityDH = (+$w('#input17').value + +(($w('#dropdown17').value) / a)) let communityPIDH = (+$w('#input18').value + +(($w('#dropdown18').value) / a)) let communityEWH = (+$w('#input19').value + +(($w('#dropdown19').value) / a)) let communityHHOH = (+$w('#input20').value + +(($w('#dropdown20').value) / a)) let communityCSH = (+$w('#input21').value + +(($w('#dropdown21').value) / a)) let communitySYH = (+$w('#input22').value + +(($w('#dropdown22').value) / a)) let communityAH = (+$w('#input23').value + +(($w('#dropdown23').value) / a)) let communityYWH = (+$w('#input24').value + +(($w('#dropdown24').value) / a)) let communitySEH = (+$w('#input25').value + +(($w('#dropdown25').value) / a)) let communityVMH = (+$w('#input26').value + +(($w('#dropdown26').value) / a)) let communityMH = (+$w('#input27').value + +(($w('#dropdown27').value) / a)) $w('#dataset3').setFieldValue('communityCoatKidsHrs', communityCKH); $w('#dataset3').setFieldValue('communityGlobWheeHrs', communityGWH); $w('#dataset3').setFieldValue('communityHabiHumaHrs', communityHHH); $w('#dataset3').setFieldValue('communityDisaHrs', communityDH); $w('#dataset3').setFieldValue('communityPhysIntDisaHrs', communityPIDH); $w('#dataset3').setFieldValue('communityEldeWidoHrs', communityEWH); $w('#dataset3').setFieldValue('communityHospHealOrgHrs', communityHHOH); $w('#dataset3').setFieldValue('communityColuSquiHrs', communityCSH); $w('#dataset3').setFieldValue('communityScoutYoutHrs', communitySYH); $w('#dataset3').setFieldValue('communityAthlHrs', communityAH); $w('#dataset3').setFieldValue('communityYoutWelfHrs', communityYWH); $w('#dataset3').setFieldValue('communitySchoEducHrs', communitySEH); $w('#dataset3').setFieldValue('communityVeteMiliHrs', communityVMH); $w('#dataset3').setFieldValue('communityMiscHrs', communityMH); //Life Activities Data Columns let lifeSOH = (+$w('#input28').value + +(($w('#dropdown28').value) / a)) let lifeMLH = (+$w('#input29').value + +(($w('#dropdown29').value) / a)) let lifeUH = (+$w('#input30').value + +(($w('#dropdown30').value) / a)) let lifePSH = (+$w('#input31').value + +(($w('#dropdown31').value) / a)) let lifeCRH = (+$w('#input32').value + +(($w('#dropdown32').value) / a)) let lifeMUH = (+$w('#input33').value + +(($w('#dropdown33').value) / a)) let lifeMH = (+$w('#input34').value + +(($w('#dropdown34').value) / a)) $w('#dataset3').setFieldValue('lifeSpecOlymHrs', lifeSOH); $w('#dataset3').setFieldValue('lifeMarcLifeHrs', lifeMLH); $w('#dataset3').setFieldValue('lifeUltraHrs', lifeUH); $w('#dataset3').setFieldValue('lifePregSuppHrs', lifePSH); $w('#dataset3').setFieldValue('lifeChriRefuHrs', lifeCRH); $w('#dataset3').setFieldValue('lifeMemoUnboHrs', lifeMUH); $w('#dataset3').setFieldValue('lifeMiscHrs', lifeMH); //Meetings $w('#dataset3').setFieldValue('meetingsBusiness', $w('#input35').value); $w('#dataset3').setFieldValue('meetingsSocial', $w('#input36').value); $w('#dataset3').setFieldValue('meetingsSpecial', $w('#input37').value); //Other Fraternal Commitments Data Columns let otherSSDH = (+$w('#input42').value + +(($w('#dropdown42').value) / a)) $w('#dataset3').setFieldValue('otherVisiSick', $w('#input38').value); $w('#dataset3').setFieldValue('otherVisiBere', $w('#input39').value); $w('#dataset3').setFieldValue('otherNumBlooDona', $w('#input42').value); $w('#dataset3').setFieldValue('otherServSickDisaHrs', otherSSDH); //Total Hours Submitted Data Column let faithdata = +faithCSH + +faithCFH + +faithPSH + +faithRVH + +faithRH + +faithSGH + +faithMH let familydata = +familyFFH + +familyFPH + +familyFWH + +familyFoFH + +familyKCH + +familyMH let communitydata = +communityAH + +communityCKH + +communityCSH + +communityDH + +communityEWH + +communityGWH + +communityHHH + +communityHHOH + +communityPIDH + +communitySEH + +communitySYH + +communityVMH + +communityYWH + +communityMH let lifedata = +lifeCRH + +lifeMLH + +lifeMUH + +lifePSH + +lifeSOH + +lifeUH + +lifeMH let otherdata = +otherSSDH let totaldata = +faithdata + +familydata + +communitydata + +lifedata + +otherdata $w('#dataset3').setFieldValue('totalHrsAdded', totaldata); wixLocation.to("/transaction-results/volunteer-hours-entry"); }
Thank you russian-dima. There is still a lot I am learning. For the past 2 yrs, the submit button was linked to the dataset to "submit" / save all the info from the code. From that reference page, I had that set because it said "You still need to call the dataset save() function or any other function that performs a save to have the new value reflecting in the collection." I am guessing something eventually stopped or was changed so the original way it was set up stopped working a few weeks ago unknowingly.
I did add in:
$w("#dataset4").save();
within the code for the submit button. Now a strange situation has come up. After making that change and publishing the site, I can go in and submit my own volunteer hours just fine. The submission shows up ok in the database collection. However when anyone else goes to add their hours, it will go through the process properly however it will not save their hours to the collection for some reason.
As for the other 2 things you called out:
1) I have never actually used the Title field any time before. None of the earlier entries from everyone had anything in that column. Because everyone has a unique membership ID, I had used that as the main reference for locating entries (on another page). What would I use the Title field for or how would it be best used?
2) Can you also help me understand what the purpose of having a setfieldvalue for the Title field in the On Ready function location is? Do I need to add in an OnReady for all of the columns in the database collection? Again, I am just trying to learn to better my knowledge.
On our submit hours page, I have a dataset that links to our membership roster. They select their name from the list and hit the Retrieve button. This performs an onClick event (sorry, I did not show that button code with the original message) that pulls 3 pieces of information from their member info (name, email, and member ID) that places it within a text field on this page. Then once they put in their hours and hit submit, all the hours plus those 3 pieces of info are added to the collection.
But again, the weird thing is it is allowing me to add new hours now but no one else's submissions are being saved. So confusing. Even though I still want to try and understand the process, I will try adding in the onready codes for each field tonight.
Thank you for your help!
Any suggestions?