Sometimes you may need to create a new custom field to handle an unmapped column in a database.
The queries below will help you do that.
- -- This is the ID we are giving our custom field definition.
- DECLARE @FieldId NVARCHAR(MAX) = 'ConNo --- CUSTOM'
- --This is a custom field for Contacts
- DECLARE @ParentType NVARCHAR(MAX) = '__M_Contacts'
- --This first part will create our custom field definition
- INSERT INTO __M_CustomField_Definitions (
- Id,
- Final_Kind,
- Final_Parent_Type,
- Final_Subject,
- Final_Visibility
- ) VALUES (
- --These are the setting for our custom field definition
- 'TextLine', --It is a text line
- @FieldId,
- @ParentType,
- 'Contact Number', --It is named 'Contact Number'
- 'Default' --It is visible
- )
- --This query creates the values.
- --In this case, we're creating a custom field definition for a contact.
- INSERT INTO __M_CustomField_Values (
- Id,
- Final_Parent_Id,
- Final_Parent_Type,
- Final_CustomFieldDefinition_Id,
- Final_Value
- )
- --This part of the query will change based on the table you are pulling values from.
- SELECT
- --SysId needs to be replaced with the column that
- --will match the Id in the __M_Contacts table
- CONCAT(SysId, ' --- ', @FieldId),
- SysId,
- @ParentType,
- @FieldId,
- con_no --This is the column that contains our custom value.
- FROM
- --This is the database and table our custom values are coming from.
- [LEGACY_TimeMatters_TestDb2].lntmuid.contact
- GO