Hello Yisrael, thank you so much for your quick response.
It has been very useful to me, but I still have to much work to do. I hope you can help me.
The page that I used for the test, has only three fields to collect the data, and a button to launch the Lightbox, so I be able to check if the result is correct.
I also include a Dataset to complete the test by recording the data obtained.
I have placed the code in the page tab of the code editor.
I also did tests with the code in the Site tab, alternating also the button between the two spaces, but the result has been the same or worse than the one I show you now.
I hope that the format is kept at least a little so that reading is more comfortable.
Below I have put the code that I used and the result on the test page.
import wixSite from “wix-site”;
import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;
// GET LIGHTBOX NAME ----------------------------------------------------------------------------------
export function iconButton1_click_1(event) {
wixWindow.openLightbox(“ADVERTENCIA ELIMINAR”); // OK - Lightbox open
let lbxcurrent = wixSite.currentPage; // FAIL - Get the page not the Lightbox
let lbxname=lbxcurrent.name; // OK, but for page not for Lightbox
let lbxtype=lbxcurrent.type; // OK, but for page not for Lightbox
let lbxinfo= lbxname + " / "+ lbxtype; // OK
$w(“#input4”).value = lbxinfo; // OK - Show the data in a page input field
$w(“#dataset1”).setFieldValue(“campo1”,lbxinfo); // FAIL - The data wasn’t saved in the dataset
// element field (it always worked fine in other
// processes over datasets with the same
// privileges in my site)
//$w(‘#dataset1’).save() // Nothing happens if I activate it
}
//---------------------------------------------------------------------------------------------------------------
// As an alternative to get the Lightbox name I used this part of code but didn’t worked either.
// Assuming the sintax is correct (probably not), no data is captured.
// Making diferent test with the sintax, in the best of cases, I get “undefined” as value, but in most
// cases nothing happened.
//let structure = wixSite.getSiteStructure(); // instead of " let lbxcurrent = wixSite.currentPage;"
//let lightboxes = structure.lightboxes; // and so on.
//let lbxinfo=lightboxes.name;
//$w(“#input4”).value = lbxinfo;
//$w(“#dataset1”).setFieldValue(“campo1”,lbxinfo);
//---------------------------------------------------------------------------------------------------------------
// GET PAGE, LOGGED USER AND USER EMAIL INFO -----------------------
$w.onReady( function () {
let current = wixSite.currentPage; // OK - Get the page
let pagename=current.name; // OK - Get the page name
let pagetype=current.type; // OK - Get the page type
let pageinfo= pagename + " / "+ pagetype; // OK - Concat name and type
$w(“#input6”).value = pageinfo; // OK - Show the data in a page input field
let user = wixUsers.currentUser; // OK - Get the logged user
user.getEmail().then((email) => {
let userEmail = email; // OK - Get the logged user email
$w(“#input7”).value= userEmail; // OK - Show the logged user email in a page input field
$w(“#dataset1”).setFieldValue(“campo3”,pageinfo); // FAIL - the data wasn’t saved in the dataset
// element field
$w(“#dataset1”).setFieldValue(“campo4”,userEmail); // FAIL - the data wasn’t saved in the dataset
// element field
//$w(‘#dataset1’).save() // Nothing happens if I activate it
})
})