Create an Author and Typist Custom Field for Documents
- --In Document Management systems that have Author and Typists,
- --Universal Migrator generally maps columns as follows:
- --Typist (the actual person who created the document) = Final_Created_By_Id
- --Author (the person the typist created the document for) = Final_Created_OnBehalfOf_Id
- --
- --It is expected that Author and Typist reference values from the __M_Users although some systems
- --Do allow these to have their own custom picklist values.
- --
- --These scripts will do the following:
- -- * Create Author and Typist custom field definitions
- -- * Create __M_CustomField_Presets (Picklist items) for each based on the __M_Users
- -- * Create Custom Field Values for each document that represent the Author and Typist.
- --
- -- Please note that this script is a TEMPLATE that is designed to be
- -- Customized per your scenario.
- --Create the Author Field
- INSERT INTO __M_CustomField_Definitions (
- Id,
- Final_Kind,
- Final_Subject,
- Final_Parent_Type
- )
- VALUES (
- 'Author',
- '__M_CustomField_Presets',
- 'Author',
- '__M_Documents_Digital_Files'
- )
- --Create Author picklist items based on users
- INSERT INTO __M_CustomField_Presets (
- Id,
- Final_CustomFieldDefinition_Id,
- Final_ReferenceCode,
- Final_Subject
- )
- SELECT
- CONCAT('Author --- ', Id),
- 'Author',
- Final_UserName, --We're using the UserName as the reference code. Maybe use Final_ReferenceCode
- Final_FullName --The picklist item is the user's full name.
- FROM
- __M_Users
- --Now create the author's custom field value
- INSERT INTO __M_CustomField_Values (
- Id,
- Final_CustomFieldDefinition_Id,
- Final_Parent_Id,
- Final_Parent_Type,
- Final_Value
- )
- SELECT
- CONCAT(Id, ' --- ', 'Author'),
- 'Author',
- Id,
- '__M_Document_Digital_Files',
- CONCAT('Author --- ', Final_Created_OnBehalfOf_Id)
- FROM
- __M_Documents_Digital_Files
- WHERE 1=1
- --Ignore blank items so we don't create garbage
- AND Final_Created_OnBehalfOf_Id != ''
- --Ignore items that don't map to a valid user so we don't create errors.
- AND Final_Created_OnBehalfOf_Id IN (SELECT Id FROM __M_Users)
-
-
- --Create the Typist Field
- INSERT INTO __M_CustomField_Definitions (
- Id,
- Final_Kind,
- Final_Subject,
- Final_Parent_Type
- )
- VALUES (
- 'Typist',
- '__M_CustomField_Presets',
- 'Typist',
- '__M_Documents_Digital_Files'
- )
- --Create Typist picklist items based on users
- INSERT INTO __M_CustomField_Presets (
- Id,
- Final_CustomFieldDefinition_Id,
- Final_ReferenceCode,
- Final_Subject
- )
- SELECT
- CONCAT('Typist --- ', Id),
- 'Typist',
- Final_UserName, --We're using the UserName as the reference code. Maybe use Final_ReferenceCode
- Final_FullName --The picklist item is the user's full name.
- FROM
- __M_Users
- --Now create the Typist's custom field value
- INSERT INTO __M_CustomField_Values (
- Id,
- Final_CustomFieldDefinition_Id,
- Final_Parent_Id,
- Final_Parent_Type,
- Final_Value
- )
- SELECT
- CONCAT(Id, ' --- ', 'Typist'),
- 'Typist',
- Id,
- '__M_Document_Digital_Files',
- CONCAT('Typist --- ', Final_Created_By_Id)
- FROM
- __M_Documents_Digital_Files
- WHERE 1=1
- --Ignore blank items so we don't create garbage
- AND Final_Created_By_Id != ''
- --Ignore items that don't map to a valid user so we don't create errors.
- AND Final_Created_By_Id IN (SELECT Id FROM __M_Users)
-
-