Converting Managed Solutions to Unmanaged Solutions CRM 2013 and 2015
If you have any doubt in the post please post comments. I will try to solve your problem with in a day.
1. Create a new staging organization in Dynamics CRM 2013 (lets say StagingOrg)
2. Import the managed solution you want to convert to unmanaged in this Organization (StagingOrg).
3. Now connect SQL server from the database of StagingOrg and run this Query after changing the name of your managed solution accordingly.
4. It will show some errors after running the script. I ignored them.
5. Now go into Settings > Customizations > Solutions > and export the solution as Unmanaged. Notice that it has become Unmanaged from managed now.
6. Save the zip file and extract it to a folder
7. Open the solution.xml file from the folder and search MissingDependency tag.
8. You will notice lot of MissingDependency elements, remove them all and self close the MissingDependency tag like this <MissingDependency />
9. Zip the files again and now import it to your development environment. Now you can import it as managed or unmanaged wherever you want.
SQL Script
declare @solutionId uniqueidentifier, @systemSolutionId uniqueidentifier
-- specify the uniquename of the managed solution you'd like to unmanage here it is StagingOrg
select @solutionId = solutionid from SolutionBase where UniqueName='SuperGridSolution'
-- DO NOT TOUCH FROM HERE ON --
select @systemSolutionId = solutionid from SolutionBase where UniqueName='Active'
update PublisherBase set IsReadonly=0
where PublisherId in (select PublisherId from SolutionBase where SolutionId=@solutionId)
print 'updated publisher'
declare @tables table (id int identity, name nvarchar(100), ismanaged bit, issolution bit)
declare @count int, @currentTable nvarchar(100), @currentM bit, @currentS bit, @sql nvarchar(max)
-- go through all the tables that have the ismanaged/solutionid flag, find the related records for the current solution and move them to the crm active solution.
insert into @tables (name, ismanaged, issolution)
select name, 1, 0 from sysobjects where id in
(select id from syscolumns where name in ('IsManaged'))
and type='U'
order by name
insert into @tables (name, ismanaged, issolution)
select name, 0, 1 from sysobjects where id in
(select id from syscolumns where name in ('SolutionId'))
and type='U' and name not in ('SolutionComponentBase') -- ignore this table because it doesn't make a difference. it does cause dependency errors on the exported solution but we can manually edit the xml for that.
order by name
select @count = count(*) from @tables
while (@count > 0)
begin
select @currentTable =name, @currentM =ismanaged, @currentS =issolution from @tables where id=@count
if (@currentM = 1)
begin
select @sql ='update ' + @currentTable + ' set IsManaged=0 where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)
print 'updated IsManaged to 0 on: ' + @currentTable
end
if (@currentS = 1)
begin
select @sql ='update ' + @currentTable + ' set SolutionId=N''' + cast(@systemSolutionId as nvarchar(100)) + ''' where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)
print 'updated SolutionId on: ' + @currentTable
end
select @count = @count -1, @currentTable = NULL
end
If you have any doubt in the post please post comments. I will try to solve your problem with in a day.
2. Import the managed solution you want to convert to unmanaged in this Organization (StagingOrg).
3. Now connect SQL server from the database of StagingOrg and run this Query after changing the name of your managed solution accordingly.
4. It will show some errors after running the script. I ignored them.
5. Now go into Settings > Customizations > Solutions > and export the solution as Unmanaged. Notice that it has become Unmanaged from managed now.
6. Save the zip file and extract it to a folder
7. Open the solution.xml file from the folder and search MissingDependency tag.
8. You will notice lot of MissingDependency elements, remove them all and self close the MissingDependency tag like this <MissingDependency />
9. Zip the files again and now import it to your development environment. Now you can import it as managed or unmanaged wherever you want.
SQL Script
declare @solutionId uniqueidentifier, @systemSolutionId uniqueidentifier
-- specify the uniquename of the managed solution you'd like to unmanage here it is StagingOrg
select @solutionId = solutionid from SolutionBase where UniqueName='SuperGridSolution'
-- DO NOT TOUCH FROM HERE ON --
select @systemSolutionId = solutionid from SolutionBase where UniqueName='Active'
update PublisherBase set IsReadonly=0
where PublisherId in (select PublisherId from SolutionBase where SolutionId=@solutionId)
print 'updated publisher'
declare @tables table (id int identity, name nvarchar(100), ismanaged bit, issolution bit)
declare @count int, @currentTable nvarchar(100), @currentM bit, @currentS bit, @sql nvarchar(max)
-- go through all the tables that have the ismanaged/solutionid flag, find the related records for the current solution and move them to the crm active solution.
insert into @tables (name, ismanaged, issolution)
select name, 1, 0 from sysobjects where id in
(select id from syscolumns where name in ('IsManaged'))
and type='U'
order by name
insert into @tables (name, ismanaged, issolution)
select name, 0, 1 from sysobjects where id in
(select id from syscolumns where name in ('SolutionId'))
and type='U' and name not in ('SolutionComponentBase') -- ignore this table because it doesn't make a difference. it does cause dependency errors on the exported solution but we can manually edit the xml for that.
order by name
select @count = count(*) from @tables
while (@count > 0)
begin
select @currentTable =name, @currentM =ismanaged, @currentS =issolution from @tables where id=@count
if (@currentM = 1)
begin
select @sql ='update ' + @currentTable + ' set IsManaged=0 where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)
print 'updated IsManaged to 0 on: ' + @currentTable
end
if (@currentS = 1)
begin
select @sql ='update ' + @currentTable + ' set SolutionId=N''' + cast(@systemSolutionId as nvarchar(100)) + ''' where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)
print 'updated SolutionId on: ' + @currentTable
end
select @count = @count -1, @currentTable = NULL
end
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.