I am trying to write data on my CMS collection using wixData insert, on a Lightbox. However, two of the fields come from a dynamic page - placed that on text5 and text6. Using the insert function on a button, only the two variables are written to the collection’s field and the other input (from input1) is blank.
import {lightbox} from 'wix-window-frontend';
import wixWindowFrontend from 'wix-window-frontend';
import wixData from 'wix-data';
let receivedData = lightbox.getContext();
$w('#text5').text = receivedData.presemail;
$w('#text6').text = receivedData.presname;
$w.onReady(function () {
$w('#text8').text = receivedData.title;
let toInsert = {
"title": $w('#input1').value,
"recepientEmail": $w('#text5').text,
"recepientName": $w('#text6').text
};
let options = {
"suppressAuth": true,
"suppressHooks": true
};
function insertdata() {
if (wixWindowFrontend.rendering.env === "browser") {
return wixData.insert("RFPs", toInsert, options)
.catch( (err) => {
console.log(err);}
)}}
$w('#button9').onClick(insertdata);
});
Any help is greatly appreciated.