Hi,
I have a simple function: once “submit1_click” is clicked, the user has to be sent to a link depending on the current item in my dataset -
export function submit1_click(event) {
let email = $w(“#marks”).getCurrentItem();
console.log(“item submitted”);
$w(“#marks”).setFieldValue(“stage”, 3);
let url = “/marks/” + email[“email”] + “/3”;
console.log(url);
wixLocation.to(url);
}
However, when the button is clicked I get this error:
Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.
url is a string, and I use the exact code for a different button, where it works fine:
export function next_click(event) {
let email = $w(“#marks”).getCurrentItem();
let url = “/marks/” + email[“email”] + “/4”;
console.log(url);
wixLocation.to(url);
}
Any ideas why the error?
Thanks!
Hey
I would make sure the datasets onReady function is used as an outside wrapper so you know the data is present. And I also think you should look at the console.log(url) and tell us what that look like.
thanks!
I use info from the dataset long before with no problem. In fact, the line just before -
$w(" #marks ").setFieldValue(“stage”, 3);
works fine.
the log seems ok:
/marks/nit@nit/4 Marks 4 (Email) Line 45
Hey
Maybe it is the @ in the url that makes it go nuts? Try to url encode the string before using it into wixLocation.to maybe?
I also have a same problem. When I submit button Get PDF which clicked is pdfButton_click_1 there is nothing happen and give an error -
Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.
Please add your issue in a new forum thread rather than bumping up an old post from 2018.
Old post being closed.