I’m trying to input the logged member ID into a CMS in Wix. I can’t find a way to do this without using code, and when I try to use code, it works but creates an additional item in the database just for the member ID insert.
I believe this happens because the other data I send im using the no-code method connecting the inputs to the specific table from the database for every input on the screen. The only way I found to insert the current logged member ID into the CMS is through JavaScript, but it’s sending twice: once via the no-code method sending all the data and once via code sending only the memberId. I can’t find a way to ensure everything is sent only once without creating 2 items in the database.
here is my code to send the memberId:
export function buttonSubmit_click(event) {
currentMember.getMember()
.then(member => {
if (member) {
const userId = member._id;
const toInsert = { "userId": userId };
wixData.insert("Empresas1", toInsert)
.then(result => {
console.log("Item inserido com sucesso:", result);
})
.catch(err => {
console.error("Erro ao inserir o item:", err);
});
} else {
console.log("Nenhum membro logado.");
}
})
.catch(err => {
console.error("Erro ao obter o membro:", err);
});
}