Hi all!
I have searched a lot about this issue and I really didn't find an answer.
I have a dynamic page (item), to be updated by member author.
I set the Collection permissions.
![](https://static.wixstatic.com/media/a27d24_67b19b9d03cd4aefa484b3dfd5ed7ce4~mv2.png/v1/fill/w_481,h_608,al_c,q_85,enc_auto/a27d24_67b19b9d03cd4aefa484b3dfd5ed7ce4~mv2.png)
Then the page displays all the fields of "Professional" properly, using the dataset read&write etc.
Now the problem is:
I can update this item of Collection, whithout any problem, but ONLY AT THE FIRST TIME.
The second time I try to update, even in the same session or logging out and in, I receive the message: "Error: The current user does not have permissions to update on the Professionals collection."
I don't understand what is happening. I can imagine it's one of two situations.
When the first update runs:
- It's overwriting the _id in a different format or;
- It's overwiriting the permitions settings, not for the Collection, but something attached to the member/user/author. I don't know.
The code is:
export function button1_click() {
let toUpdate = {
"_id": wixUsers.currentUser.id,
"name": $w("#input1").value,
"email": $w("#input2").value,
"phone1": $w("#input3").value,
"phone2": $w("#input4").value,
"address": $w("#input5").value,
"city": $w("#dropdown1").value,
"facebook": $w("#input6").value,
"instagram": $w("#input7").value,
"site": $w("#input8").value,
"description": $w("#textBox1").value,
"picture": $w("#image4").src,
"isProfessional": true
};
wixData.update("Professionals", toUpdate)
.then( (results) => {
let item = results; //see item below
$w("#input9").value = "UPDATED"; //It's my log
} )
.catch( (err) => {
let errorMsg = err;
$w("#input9").value = err; //It's my log
} );
}
Could anyone tell how to solve this?
Thanks in advance.
Wow, Shay!!
Finally I've got the answer!! Your explanation is right!! I didn't know about the _owner field and, yes, the first record was overwriting this field and the item was with no owner anymore.
Thank you so much!!
Regards!!
Hi,
Each item has the next two system fields:
_owner - holds wixUsers.currentUser.id and handles the access permissions.
_id - unique Id of an item.
The code should look like:
let toUpdate = { "_owner":wixUsers.currentUser.id, "_id":itemYouGotFromDB._id, ...rest of your fields }
Hi,
it seems you are hitting a known issue. By updating the record, you are losing the _owner field (owner of the record is allowed to change the field value). This field is used to determine who is the owner of the record. So, effectively, after update, no one owns the record. Is there a chance, that you could copy _owner field value from an existing record?
Shlomi Shemesh,
any progress? It's taking me to much time researching about this. At this point, the members registered at my site are able to update their data information only once. This is not a good practice.
I'm almost giving up on it.
Regards!
Hi,
i'll pass your question within wix to the relevant team to further look into this
thanks,
Shlomi