I created a custom sign-up form for my site that allows for me to capture additional information from my members. Upon successful registration, the additional details are saved to both the Contact record in the CRM as well as a Data Collection. This works perfectly.
I have also created a Members Page that retrieves the members additional info from the collection and displays it for the member to update/change. When the member submits the form, I update the collection, and then, using the onAfterSave event, I call the createContact() method of the WixCRM API to update the members contact record. Which, according to the documentation, if the email address or phone number already exists, the contact record should be updated instead of a new one being created.
However, when I submit the form, the createContact() method returns “Uncaught (in promise) permission_denied, details: {“Error”:“A member with these communication details (Email / Phone) already exists”} (403)”
This error is a bit confusing since the expected result of an existing member should be an updated contact record, not an error. Here is the code I am using…
$w("#dataset1").onAfterSave((itemBefore, itemAfter) => {
changeLabel();
let contactInfo = {
"firstName": itemAfter.firstName,
"lastName": itemAfter.lastName,
"loginEmail": loginEmail,
"emails": [itemAfter.email],
"phones": [itemAfter.phone],
"birthday": itemAfter.birthday,
"gender": itemAfter.gender,
"shirtSize": itemAfter.shirtSize,
"passport": itemAfter.passport,
"emergencyFirstName": itemAfter.emergencyFirst,
"emergencyLastName": itemAfter.emergencyLast,
"emergencyPhone": itemAfter.emergencyPhone,
"emergencyEmail": itemAfter.emergencyEmail,
"foodIssues": itemAfter.foodIssues,
"medicalIssues": itemAfter.medicalIssues,
"medications": itemAfter.medications
};
wixCrm.createContact(contactInfo);
});
Any help on this would be appreciated!