In Wix Studio i am trying to use onProductCreated() to add the basic product information to CMS, the CMS permission setup as all can view, add, and update to avoid any problem and I followed Velo document, but the code is not work, any body can help on that. kindly advise.
import wixStoresBackend from "wix-stores-backend";
import wixData from 'wix-data';
export function wixStores_onProductCreated(event) {
let productId = event._id
let productName = event.name;
let productDescription = event.description;
let toInsert = {
"title": productName,
"product": productId,
"description": productDescription,
};
wixData
.insert("ProductAdditionalInfo", toInsert)
.then((item) => {
console.log(item); //see item below
})
.catch((err) => {
console.log(err);
});
}
Allowing all to add/edit/view from a CMS collection would not avoid trouble, it’ll only invite it - Now anyone can just modify your contents to their whim. Instead, use elevate or surpassAuth so that the backend functions are executed with the server’s limitless permissions
The ProductCreatedEvent does not contain a property called ‘description’
As for the actual cause of your problem, I do not know, sorry