Question:
I created a custom field called Contact Source for my Wix contacts. I built an API to export new contacts to mailchimp. Everything is working well in the API except I don’t know how to refer to the custom field.
Product:
Wix Editor/Dev Mode
What are you trying to achieve:
List the extended fields so I can see what the fieldkey is for the custom field I am trying to reference.
What have you already tried:
queryExtendedFields - Velo API Reference - Wix.com
Additional information:
This is my code. I get an error under the line “const items = queryResults.items;” The error is “Property ‘items’ does not exist on type ‘Promise’.”
import { createMailchimpContact } from 'backend/mailchimp';
import { extendedFields } from 'wix-crm.v2';
import { contacts } from 'wix-crm-backend';
export function wixCrm_onContactCreated(event) {
const contactId = event.metadata.entityId;
const contactEmail = event.entity.primaryInfo.email;
const contactSource = event.entity.info.extendedFields.contact_source; //this is where I am trying to get the custom field
console.log('Contact created', contactEmail, contactSource);
createMailchimpContact(contactEmail, contactSource)
}
export function myQueryExtendedFieldsFunction() {
try {
const queryResults = extendedFields.queryExtendedFields()
.find();
const items = queryResults.items; //this is the first error
const firstItem = items[0];
const pageSize = queryResults.pageSize;
const hasNext = queryResults.hasNext();
const hasPrev = queryResults.hasPrev();
const length = queryResults.length;
const query = queryResults.query;
return items;
} catch (error) {
console.error(error);
// Handle the error
}
}