Hi, Trying to use a reference field from a collection.
It shows in the table element as I wanted, but then I have function that export this data to a text file.
The process is very easy, but I’m stuck in trying to the get value from the “coursename” that is from the reference collection (refEventName:). I pasted below where it’s showing I output the value to the console, but I unable to get the value out it.
Any help will be appreciated.
My Code:
function getCourseName(items) {
console.log(items);
//let myscore = myitems.items[0];
//let mycourse = myscore.refEventName.course;
const nameOnly = items.map(item => item.course);
console.log(nameOnly);
return [...new Set(nameOnly)];
//return mycourse;
}
export function button1_click(event) {
//Get items from Table element.
let items = $w('#tblweekPlayers').rows;
getCourseName(items);
items = items.map(function (obj) {
//only shows the columns that you want
//console.log(obj);
const coursename = getCourseName(obj)
return { PlayerName: obj.player_name, GrossScore: obj.gross_score, NetScore: obj.net_score, Handicap: obj.handicap, EventID: obj.eventID, EventName: '' };
});
}
Output from "console.log(items); " inside function getCourseName()
{…}
→ refEventName: {…}
_id:
“4b1a4f7c-adcf-44be-ba63-a4712f11d7b1”
_owner:
“68c05680-eea4-4b96-a070-5536ba1f4eba”
_createdDate:
“2020-06-28T15:55:36.743Z”
category_name:
“A”