I am creating a team site and would like to display data from the field position and location in one text field. Im using dynamic sites an a repeater for each member.
Ive come up with the code below:
$w.onReady(() => {
const dataset = $w( “#dynamicDataset” );
dataset.onReady(() => {
const { position , branch } = dataset.getCurrentItem();
$w( “#text250” ).text = ${position} | ${branch}
;
});
});
However instead of fetching the unique data ‘position’ and ‘branch’ for each team member, it keeps repeating the same data from the first person in the data set…
Does anyone know the solution to this? Thanks allot!!
Try to debug your code, by using some console.logs…
$w.onReady(() => {
const dataset = $w("#dynamicDataset");
dataset.onReady(() => {
let xxx = dataset.getCurrentItem(); console.log(xxx)
//const { position , branch } = dataset.getCurrentItem();
//$w("#text250").text = `${position} | ${branch}`;
});
});
What do you get as result for —> xxx ?
Can you create a new —> const of —> the given result? Does it fit?
A currentItem could look like this…let xyz = dataset.getCurrentItem();
xyz = {
"_id": "fcec780a-3e37-4b64-8a66-37c552c53f99",
"_owner": "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
"_createdDate": "2021-04-01T17:19:03.823Z",
"_updatedDate": "2021-04-01T17:19:10.477Z",
"title": "title",
"position": "xxx",
"branch": "zzz"
}
Now you want to get some values…
const title = xyz.title
const position = xyz.position
const branch = xyz.branch
and so on…