Changing Field Types

SOLVED

I currently have a field type of selection, which only allows you to select one item in the list. Would it be possible to change the type selection to type multiselection? There's already information in the old field and I really would like to not abandon that information (or maybe is there a way to create the new multiselect field and populate it with the old select information for each record?)

  • 0

    Yes. You will need to change the settings in custom_edits table as well as wrapping the existing text it , and ,. If you find another field in custom_edits thats a multi select and replicate the config settings required into the required selection field settings in custom_edits it will change the field type in CRM. Multi selects uses comma's to differential the options so you will also need to change the text from, for example "Customer" to ",Customer,".

  • 0

    Right! I found the field I want to change and a field that I want to turn it into. I see that I'll have to change the entry type, entry size, and the data size.

    However, while I see that use of commas, I'm not sure behind the code to do that (change the text form).

    When I just change the entry type, and then add a few new multiple selections I get an error:

    An unexpected event has occurred: SQL Code: 8152
    SQL Code: 3621
    Exception: SQL Error

    If I change those other settings I'm hoping it'll go away.

    Now my guess to adding the commas, would look something like this?

    UPDATE Opportunity
    SET oppo_assignedtech = CONCAT(',',oppo_assignedtech,",")

  • 0

    Try

    UPDATE Opportunity

    SET oppo_assignedtech = ','&oppo_assignedtech&','

  • 0

    Well, it looks like I just updated the field with the information

    UPDATE Custom_Edits

    SET ColP_EntryType = 28, ColP_EntrySize = 5, ColP_DataSize = 255

    WHERE ColP_ColPropsId = '11594'

    It worked when I tried to create a new opportunity, and then worked again when I tried to modify an old field (click the change button and then multi-select).

    I haven't done the update to add the commas, are you sure it's necessary?

    ALSO!

    When I try

    UPDATE Opportunity
    SET oppo_asstech2 = ','&oppo_asstech2&','
    WHERE oppo_asstech2 IS NOT NULL

    I get an error: "The data types varchar and nvarchar are incompatible in the '&' operator. So I tried:

    UPDATE Opportunity
    SET oppo_asstech2 = ','+oppo_asstech2+','
    WHERE oppo_asstech2 IS NOT NULL


    And I get "String or Binary data would be truncated. The statement has been terminated."

  • 0

    I figured it out. When making the changes, the UPDATE to the record should be just done all at once, and for adding the commas, I really wish there was a webiste that told you the correct SQL commands. I've got SQL SERVER 2008 R2 so sometimes certain commands for other SQL versions don't work, and it can be frustrating.

  • +1 in reply to Tebasaki
    verified answer

    Hi,

    as I've used your post to find the solution, please let me give two major updates for this script that are missing in your post in order to avoid any issue if someone follow exactly what you have done :

    1) your script changes the field for the metadata but does not consider the real database field size, so it is required otherwise a user that would select multiple values up to 31 char will generate an SQL exception when saving the record.

    In your example :

    ALTER TABLE [Opportunity]
    ALTER COLUMN [oppo_asstech2] nvarchar(255) 

    2) if the field is followed by the tracking engine of the entity to be modified, just like opportunity in your example could be tracked by OpportunityProgress entity, the same field in the "progress" entity (and its content) must be updated too.