Recently I came across a situation where my local optionset was pointing to one global optionset and then I needed to point to another global optionset. In CRM to do this, you would have to drop the field and recreate field. But the problem is if you have a running system which is being actively used, you may not be at the luxury of dropping and recreating the fields. Let’s see how we can overcome this situation.
Before continuing, please note that the below procedures is not recommended by Microsoft and interacting directly with CRM Organization database might cause CRM to work incorrectly and following the recommended way is what you should look for. I would strongly recommend taking a back-up of your customizations and organization database.
But say we need it to map to another Global optionset called “Global Optionset 2”. To do the same, open the CRM Organization database and run the below SQL query on the database.
DECLARE @OptionsetId UniqueIdentifier
SET @OptionsetId = (Select OptionSetId from OptionSet where Name = ‘new_globaloptionset2’)
Update Attribute SET OptionSetId = @OptionsetId WHERE LogicalName = ‘new_testlocaloptionset’ and EntityId = (SELECT top 1 EntityId From Entity where LogicalName = ‘contact’)
After this query is executed, when CRM is re-opened we could see that our Local Optionset set is now pointing to the “Global optionset 2” instead of “Global Optionset 1”
Now there is a question as to what should be with the existing data for the field. For that a simple console batch to update the previous values with the new values using text matching condition would resolve the problem. This can be easily achieved with CRM SDK Code. Hope this helps! Happy coding.