Inject content from database into page element

Hi guys, I’m currently trying to inject content from a database, with ID = BroomhillPark, into a page element called #energyRatingDescription. I’m trying to inject a field called shortDescription, from the BroomhillPark database, to override the filler text with id #energyRatingDescription". So far I’ve written this, which does work, but I’d like to use the current dynamic pages “name” value so the shortDescription of each record is inserted when viewing their specific product page:

import wixData from ‘wix-data’;
$w.onReady( function () {
wixData.query(“BroomhillPark”)
.find()
.then( (results) => {

$w(“#energyRatingDescription”).text = results.items[0].name;
} );

} );

I’ve then set #energyRatingDescription to be hidden on default and I’ve used .show() when a button, #energyRating, is clicked. Each page is advertising a different product so I’d like to display the shortDescription specifically for that product. I feel it will involve using the “this” keyword, or some type of loop, but my knowledge of jquery/corvid isnt amazing.

Have you tried simply just linking the #energyRatingDescription element through the element’s own data link settings to the correct field in your BroomhillPark dataset itself and seeing if it shows the correct data for that dynamic page already?

Through code you can look at getting the current item from the dynamic dataset.
https://www.wix.com/corvid/reference/wix-dataset.DynamicDataset.html#getCurrentItem

$w("#dynamicDatasetName").getCurrentItem().shortDescription;
//shortDescription is the field you want to get its text right?

Was working late last night and completely forgot that was an option… But everything’s working fine now. Thanks!