When creating 2 or more contacts in my preview page I am able to make multiple contacts. 1 of the contacts has an email and phone number attached to it the other contacts just have a name and other tags filled out .
The problem arises when I try the same code when publishing the site. Instead of creating multiple contacts it just merges all of the contact information together creating 1 contact with all the tags of the 2+ contacts.
Anyone have any clue why the published site would act differently when appending or creating contacts?
Can you share the code that isn’t working when published?
import { contacts } from 'wix-crm-frontend'
$w.onReady(function () {
$w('#submit').onClick(async (event) => {
console.log("test");
const contactInfo1 = {
name: {
first: "Ari",
last: "Thereyet"
},
emails: [{
email: 'test@gmail.com'
}],
phones: [{
tag: "MOBILE",
countryCode: "US",
phone: '6129998888'
}],
labelKeys: [
"custom.can-text"
]
};
const contactInfo2 = {
name: {
first: "Not",
last: "Thereyet"
},
birthdate: "2004-08-23",
labelKeys: [
"custom.player"
]
};
try {
const playerContact = await contacts.appendOrCreateContact(contactInfo1);
const guardianContact = await contacts.appendOrCreateContact(contactInfo2);
} catch (error) {
console.error(error);
}
});
});
This leads to a contact being made called Ari Thereyet that has the labels ‘player’ and ‘can text’ but those should be independant so I dont know why this occurs
Seems that this behavior is because multiple contacts are being created from the same browser session:
So when a contact exists that is the one that gets updated.
If you need to create multiple contacts from a single browser session then you can use createContact
on the backend and then a Velo Web Module to call it from the frontend.
If you don’t need to update contacts then that’s all there is to it. If you do then you’ll need to use queryContact and updateContact on the backend as well.
1 Like