EDIT:
Turns out custom field in contactInfo must be the same as the display name and not the key. Same goes for labels.
This behaviour is different to the contacts API in wix-crm-backend , where updateContact expects the custom field key.
the payload object now looks like this
//payload object
"payload": {
"contactInfo": {
"firstName": "test",
"lastName": "test"
//uses custom field display names
"Custom 1": "test",
"Custom with-hyphen": "yes",
"Custom with-hyphen 2": "no"
}
}
Hello all, I’ve been working on a custom registration page that calls register() in the backend. It receives the contactInfo object, but only saves the firstName and lastName keys. none of the custom fields are saved. The code is as follows:
registrations.jsw
export async function doRegistration(email, pw, payload) {
const { contactInfo, page } = payload
const resOptions = {
contactInfo
}
try {
const res = await authentication.register(email, pw, resOptions)
await triggeredEmails.emailMember('id', res.member._id, {
variables: {
confirmUrl: `domain/regis-conf?tk=${res.approvalToken}&pg=${page}`
}
})
return res
}catch (error){
console.error(error)
return error.toString().includes("already exists") ? "Email already exists" : error.toString()
}
}
The resOptions object that is being passed to register():
{
"contactInfo": {
"firstName": "test",
"lastName": "test",
//the fields below aren't saved
"custom1": "town",
"custom-with-hyphen": "yes",
"custom-with-hyphen-2": "no"
}
also tried it like this and it didn’t work
{
"contactInfo": {
"firstName": "test",
"lastName": "test",
//the fields below aren't saved
"custom.custom1": "town",
"custom.custom-with-hyphen": "yes",
"custom.custom-with-hyphen-2": "no"
}
The registration is successful, and the user receives a confirmation email, but none of the additional data is saved.
I’ve checked the keys for birthdate and custom fields and they seem to be all correct, but it’s not persisting.
What am I missing?