Previously this was working. I am trying to get fullName displayed on page from a collection. I have created an after query which is active.
The script for this is as follows
// In file backend/data.js
export function MemberData_afterQuery(item, context) {
item.fullName = item.FirstName + " " + item.LastName;
return item;
}
export function PrivateMembersData_afterQuery(item, context) { item.fullName = item.FirstName + " " + item.LastName; return item; }
//the script on the page in question is
$w.onReady(function() { $w("#dataset1").onReady(() => { populateCalculatedFields(); } ); $w("#dataset1").onCurrentIndexChanged( (index) => { populateCalculatedFields(); } ); } ); function populateCalculatedFields() { const currentItem = $w("#dataset1").getCurrentItem(); $w("#textFullName").text = currentItem.fullName;
}
// When the page loads the elements that have been connected using a dataset show, undefined, undefined
and the collection has a new entry in the row above where i would expect the fullName to be 'collected' from i.e. the last field of fullName which is correctly populated from the After Query setup.
There are no errors in the console when in preview mode
Can anyone suggest why this might be happening?
Thanks
Adam
so really the actual problem is... how can i submit a new form user input to an existing row in collection without the database creating a new row. If i can do this then i can collect the full name
OK so i think i know why this is happening. On a previous page i submit a new form field to the same collection, it adds a new row which is correct function wise but not what i'm looking for. The additional form field submissions should populated the last 'semi' complete row, otherwise when subsequent pages load i.e. the page that show the fullName, it will show undefined as there is no data in the new row to collect from.