(SOLVED) How do you access the Dynamic URL of a database entry via code?

HI

I have a page that selects database entries from a list of exercise workouts via a drop down.

What i need to be able to do is on change of that drop down is select the name of that exercise and have it populate the associated dynamic URL into another text element.

Here is where im at with it, the issue is around the field key of the dynamic URL it doesn’t handle correctly the - minus signs in the field key. i tried to put it in brackets but this didn’t work either.

The element populates but just as text it doesn’t put in the correct URL from the database.

I can see the correct URL in the console log i just cant get it to put that URL in the element. i must be close! please help.

export function trainingStencildropdown1_change(event) {

return wixData.query(“TrainingStencils”)
.eq(“trainingDaydescriptiontextbox”,$w(‘#trainingStencildropdown1’).value)
.find()
.then( (results) => {

let URL = [‘link-trainingstencils-trainingDaydescriptiontextbox-_id:’]; // “/trainingstencils/Chest%2C-Shoulders-calves-and-triceps-(Womens)/30a677b6-210c-4fcd-a28a-cbf04f639ece” ;
console.log(results)
$w(‘#stencilUrltextbox1’).text = URL.toString();
});
}


Solved myself

// Training day functions
export function checkBox1_change(event) {
return wixData.query(“TrainingCollection”)
.eq(“exercise”,$w(‘#exerciseDropdown’).value)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
let trainingUrlLink = item.trainingUrlLink;
let _id = item._id;
$w(‘#urlTextbox1’).value = item.trainingUrlLink.toString();
$w(‘#workOutlink1’).text = item.trainingUrlLink.toString();
$w(‘#trainingId1’).text = item._id.toString();
console.log(“Training URL link = “,trainingUrlLink,” “, “Database _id = “,_id);
let ischecked = $w(”#checkBox1”).checked
if ($w(‘#checkBox1’).checked === true ) {
$w(‘#trainingTextbox1’).value = $w(”#exerciseDropdown”).value
} else {
($w(‘#checkBox1’).checked === false )
$w(‘#trainingTextbox1’).value = “”
$w(‘#infoTextbox1’).value = null
$w(‘#warmUpsetsdropdown1’).value = null
$w(‘#workingSetsdropdown1’).value = null
$w(‘#repsDropdown11’).value = null
$w(‘#repsDropdown12’).value = null
$w(‘#repsDropdown13’).value = null
$w(‘#repsDropdown14’).value = null
$w(‘#repsDropdown15’).value = null
$w(‘#urlTextbox1’).value = “”
$w(‘#workOutlink1’).text = “”
}
})
}

Looks like you’re on a roll.

I have trouble on this:

The automatically generated field key is “link-proposals-title-_id” and when I do

console.log("saved item is ", item);

I can see item.link-proposals-title-_id is listed in the result.

However, if I try to use it in code:

wixWindow.to(item.link-proposals-title-_id);

Then, there is compilation error:

proposals is not defined, title is not defined, _id is not defined.

Seems like that

link- is some keyword 

Appreciate any help