Hello again,
i have played a little bit with your code and have created a little example for you.
I think this is some kind of what you want to do…
https://russian-dima.wixsite.com/meinewebsite/autoupdate-picture
import wixData from 'wix-data';
import wixUsers from 'wix-users';
var picData
var ownerId
var membersData
$w.onReady(function () {
$w("#dataset1").onReady( () => {
let userId = wixUsers.currentUser.id
console.log(userId)
wixData.query("Member-Data")
.eq('_owner', userId)
.find()
.then( (results) => {
membersData = results.items[0];
console.log(membersData)
ownerId = membersData._owner;
console.log(ownerId)
picData = results.items[0].profilePic
console.log(picData)
$w('#input1').value=userId
$w('#input2').value=userId
$w('#image1').src=picData
})
.catch( (err) => {
let errorMsg = err;
});
$w('#dataset2').onBeforeSave(()=>{console.log("Prepare-Data")
$w("#dataset2").setFieldValues( {
"title": $w('#input1').value,
"comment": $w('#textBox1').value,
"userPic": picData
});
console.log(picData)
})
$w('#button1').onClick(()=>{console.log("Save-Data")
$w("#dataset2").save()
})
})
})
As you can see, it also works in front-end-mode (only if using own Member-Database) !!!
Of course you have to optimize this CODE.
-Giving the code a REFRESH-FUNCTION.
-Optimize DATE & TIME
-Optimize the OUTPUT-DATA (Name / First-Name and so on)
-and doing some more optimizations, till you have a good working comment-function.
Good luck & happy coding.