Field Key parameter with special characters

Hi Guys
I am really stuck here and will truly appreciate your support. Basically, I am trying to pass that “field Key” as a parameter in the following code snap: the field key is from a collection/dataset which stores information about artists including a link to the artist dynamic page(which is normally created by the system when you create setup dynamic page) . I wish to fetch the link and use it to open the individual artist page.

export function LoginButton_click(event) {
 let username = $w('#username').value;
 let passkey = $w('#password').value.r;
      wixData.query("Artist")
      .eq("title", username)
      .eq('StoredPassword', passkey)
      .find()
      .then((results) => {
        if(results.items.length>0)
        {
        let link = results.items[0].link-artist-1-title; //this is where the problem is
         wixLocation.to(link);                          //system doesn't  "-"
        }                                               //as show below
        else if (results.items.length === 0) {
        //$w('#text13').show();
 
           }

        })
          .catch((err) => {
           console.log("err", err);
         });
 
   }
 
 
 

the field key is generated automatically by the system when I created the dynamic page (there is no way to change it). I tried to stored it in string and pass

it like this,

let temp = "link-artist-1-title"; //store the string in a variable
then...
ink = results.items[0].temp; //won't work

also you can't passed like this

ink = results.items[0].'link-artist-1-title'; //won't work

I am willing to provide more information upon your request.

1 Like

old-version…

ink = results.items[0].temp; //won't work

test-version…

ink = results.items[0][temp] //???

or —>

let temp = ["link-artist-1-title"]; //store the string in an ARRAY

+++

ink = results.items[0][temp[0]] //???

Worked so Perfect Sir! you are the genius and you saved me a whole night. thank you, thank you so much

No problem! You are welcome. :wink:
And do not forget to like it, if you realy liked it :grin:

1 Like

This post helped me after hours of trying to send a dynamic link via email. I used the step where I saved the known key as a temperary variable in an array, and referenced that value while referring to the item being retrieved from the the dataset. Thank you for that idea.

No problem. This one is already an older post :grin: