> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: findOrCreateExtendedField(displayName: string, dataType: FieldDataType) # Method package: wixCrmV2 # Method menu location: wixCrmV2 --> extendedFields --> findOrCreateExtendedField # Method Link: https://dev.wix.com/docs/velo/apis/wix-crm-v2/extended-fields/find-or-create-extended-field.md # Method Description: Retrieves a custom field with a specified name, or creates one if it doesn't exist. The number of custom fields is limited to 100. Successful calls to this method always return a field, which can be specified in subsequent calls. To find an existing custom field without potentially creating a new one, call Get Extended Field or Query Extended Fields. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create an extended field (dashboard page code) ```javascript import { extendedFields } from 'wix-crm.v2'; /* Sample displayName value: * * 'Age' * * Sample dataType value: * * 'NUMBER' */ export async function myCreateExtendedFieldFunction(displayName, dataType) { try { const newExtendedField = await extendedFields.findOrCreateExtendedField(displayName, dataType); console.log('Successfully created new extended field:', newExtendedField) return newExtendedField; } catch (error) { console.log(error); // Handle the error } } /* Promise resolves to: * { * "field": { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * "newField": false * } */ ``` ## Create an extended field (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { extendedFields } from 'wix-crm.v2'; import { elevate } from 'wix-auth'; /* Sample displayName value: * * 'Age' * * Sample dataType value: * * 'NUMBER' */ export const myCreateExtendedFieldFunction = webMethod(Permissions.Anyone, async (displayName, dataType) => { try { const elevatedCreateExtendedField = elevate(extendedFields.findOrCreateExtendedField); const newExtendedField = await elevatedCreateExtendedField(displayName, dataType); console.log('Successfully created new extended field:', newExtendedField) return newExtendedField; } catch (error) { console.log(error); // Handle the error } }); /* Promise resolves to: * { * "field": { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * "newField": false * } */ ``` ## Find an extended field ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { extendedFields } from 'wix-crm.v2'; import { elevate } from 'wix-auth'; /* Sample displayName value: * * 'Nickname' * * Sample dataType value: * * 'TEXT' */ export const myFindExtendedFieldFunction = webMethod(Permissions.Anyone, async (displayName, dataType) => { try { const elevatedFindExtendedField = elevate(extendedFields.findOrCreateExtendedField); const newExtendedField = await elevatedFindExtendedField(displayName, dataType); console.log('This extended field already exists.'); return newExtendedField; } catch (error) { console.log(error); // Handle the error } }); /* * Promise resolves to: * { * "field": { * "namespace": "custom", * "key": "custom.nickname", * "displayName": "Nickname", * "dataType": "TEXT", * "fieldType": "USER_DEFINED", * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1", * "wixSearchColumn": "info_extendedFields_custom_string_18", * "_createdDate": "2023-12-25T12:21:42.000Z", * "_updatedDate": "2023-12-25T12:22:25.000Z" * }, * "newField": false * } */ ``` ---