I’m trying to get the url from a dynamic page and then insert it (along with the user Id) into a collection when clicking a submit button. Somehow the _Id and the owner are being inserted but the url is not.
Thanks for the help
Here’s the code i’m using
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
export function applyCampaign_click(event) {
//Add your code for this event here:
let user = wixUsers.currentUser; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true let url = wixLocation.url
import wixUsers from ‘wix-users’; import wixLocation from ‘wix-location’; import wixData from ‘wix-data’;
let url = wixLocation.url; let user = wixUsers.currentUser; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true
let toSave = {
“_id”: userId,
“title”: url,
};
export function applyCampaign_click(event) {
//Add your code for this event here:
Hey JD, I tried the code but still get empty fields . Don’t get’s wrong
import wixUsers from ‘wix-users’; import wixLocation from ‘wix-location’; import wixData from ‘wix-data’;
let url = wixLocation.url; let user = wixUsers.currentUser; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true
let toInsert = {“userId”: userId, “title”: url};
export function applyCampaign_click(event) {
wixData.insert(“#InfCampReq”, toInsert)
.then( (results) => { let item = results;
} )
. catch ( (err) => { let errorMsg = err;
} );
}
@jonatandor35 Hello, I have similar issue, maybe more easier. I am using WIX Form for inquiries on each Product page. When somebody submitting the Form I need to know for which product he is interested in. Here will be the solution to get together with the message (inquiry) the URL or the name of the product from the page where it was submitted. I cant programming the code, hopefully you can help me with creating the ready code. We also can talk about the freelancer task fr some budget.