Question:
Hi, I am stuck, and I hope the answer is simple. I am reading a database value called the applicationID from a database table as a number. I increment that number as this will be a form application ID. I store that data into a session (so it can be retrieve across multiple web pages). I populate that number into an input number box. That number box is connected to the CMS database. when I send the data to the CMS database everything works except the number.
I am thinking…
since the session data number is set in the inputbox.value for some reason when I validate the data using Captcha that data isn’t being picked up
Product:
Wix Studio Editor with Dev Mode enabled
What are you trying to achieve:
Taking the session number after i increment it and use that as an application ID and upload that into the database as a primary ID key for linking all new applicant data across multiple database tables.
What have you already tried:
I have tried using text fields, input text, input number, database type number, database type text, I have tried setting the input box to valid… still nothing??? I have validated that the database permissions are set to “anyone can view content” and “anyone can add content.” What I noticed is if I manually enter a number replacing the applicationID, that number will go into the database, but not the automated session number that has been set as the value of the input box.
Additional information:
Here is my front end code, I am focused on uniID, it all populates fine. but the data isn’t going into the database. Is session data a special type (other than string or integer)?
Any help greatly appreciated, I am running out of ideas.
site: www.PrivateTacticalArmory.com
Page: Tb
import {session} from ‘wix-storage-frontend’;
import wixData from ‘wix-data’;
import {process} from ‘backend/submitT1.jsw’;
import wixLocation from ‘wix-location’;
//Variables
const collectionAppID = “AppID”;
const appIDKey = “bc5e76e2-6b5e-4099-8392-9ede9be72d34”;
let appNumberInc = 3;
var newAppID = 0;
$w.onReady(function () {
wixData.get(collectionAppID, appIDKey)
.then((item) => {
//Increment the starting applicaiton number
let newAppID = (item.appId + appNumberInc);
//Get new applicant number
$w("#uniIDText").value = newAppID;
//Set session key and value of the new applicantID
session.setItem ("AppKey",newAppID);
//Get session value using key
$w('#uniID2Text').value = session.getItem("AppKey");
$w('#uniID').value = session.getItem("AppKey");
//Set uniID to validated
$w('#uniID').valid;
})
//Captcha on timeout
$w('#captcha1').onTimeout( () =>{
$w('#submitbtn').disable();
})
//Captcha on error
$w('#captcha1').onError( () =>{
$w('#submitbtn').disable();
})
//Captcha is verified
$w('#captcha1').onVerified( () =>{
$w('#submitbtn').enable();
})
});
//Submit button event validations
export function submitbtn_click(event) {
if($w(‘#firstName’).valid
&& $w(‘#lastName’).valid
&& $w(‘#uniID’).value){
//$w(‘#errorText’).hide();
//Create an object
let objTb = {
//Token
token: $w('#captcha1').token,
//nested wix-data obj
wix_data_obj:{
firstName: $w('#firstName').value,
lastName: $w('#lastName').value,
uniID: $w('#uniID').value
}
};
//Send object to the backend & receive
process(objTb)
.then( (res) =>{
if(res.success){
//wixLocation.to(`${wixLocation.url}`); //refresh page if sucess
}
});
}
else {
$w('#errorText').show();
$w('#errorText').text = 'Incomplete entries, please correct.';
$w('#submitbtn').disable();
$w('#captcha1').reset();
}
}