Friday 21 December 2012

AX Dynamics Connector

I recently hit this random error with the Microsoft AX Dynamics connector when try to configure the CRM org.

The following exception occurred while attempting to retrieve all companies: Could not load type 'Microsoft.Xrm.Sdk.Client.IServiceManagement`1' from assembly 'Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

All I did to fix it was move the Microsoft.Xrm.Sdk.dll from the C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Crm2011 folder and copy it into the root folder for the dynamics adapter install.

It seems the installer may have not moved that required file and the configuration wizard is from within that folder.

Monday 10 September 2012

Tech Ed 2012

It has been a long time since my last post, anyhow currently I'm at Tech Ed and I figured I would blog about a cool session I attended regarding CRM 2011 and tips and tricks.

Gayan Perera from Magnetism ran the session and mentioned a really cool generation tool to replace the crmsvcutil tool from the sdk.  It has now been released on code plex and allows generation of code using templating, this is a lot more flexible than the current tool and easier to work with.  Check it out here: http://crm2011codegen.codeplex.com/

The other cool information was turning managed solutions into unmanaged solutions using SQL, it makes the org unusable but if done on an import of a copied database the solution can be exported and imported where required.

Kudos to Gayan and Thomas getting this SQL running:

declare @solutionId uniqueidentifier, @systemSolutionId uniqueidentifier -- specify the uniquename of the managed solution you'd like to unmanage
select @solutionId = solutionid from SolutionBase where UniqueName='Your Solution Name'
select @systemSolutionId = solutionid from SolutionBase where UniqueName='Active'

declare @sql nvarchar(max)
select @sql ='update PublisherBase set IsReadonly=0 where PublisherId in (select PublisherId from SolutionBase where SolutionId=N'''+cast(@solutionId as nvarchar(100))+''')'
print (@sql)
exec (@sql)

declare @isManagedTables table (id int identity, name nvarchar(100))
declare @count int, @currentTable nvarchar(100), @currentM bit, @currentS bit
-- 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 @isManagedTables (name)
select name from sysobjects where id in 
(select id from syscolumns where name in ('IsManaged')) 
and type='U'
order by name
select @count = count(*) from @isManagedTables
while (@count > 0)
begin
select @currentTable =name from @isManagedTables where id=@count
select @sql ='update ' + @currentTable + ' set IsManaged=0 where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
print (@sql)
exec (@sql)
select @count = @count -1, @currentTable = NULL
end

declare @isSolutionIdTables table (id int identity, name nvarchar(100))
insert into @isSolutionIdTables (name)
select name 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 @isSolutionIdTables
while (@count > 0)
begin
select @currentTable =name from @isSolutionIdTables where id=@count
select @sql ='update ' + @currentTable + ' set SolutionId=N''' + cast(@systemSolutionId as nvarchar(100)) + ''' where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
print (@sql)
exec (@sql)
select @count = @count -1, @currentTable = NULL
end

-- Remove dependencies BaseSolutionId
delete from DependencyBase where DependentComponentNodeId in (
select DependencyNodeId from DependencyNodeBase where BaseSolutionId=@solutionId
)
alter table DependencyBase NOCHECK CONSTRAINT dependencynode_ancestor_dependency 
delete from DependencyNodeBase where BaseSolutionId=@solutionId
alter table DependencyBase CHECK CONSTRAINT dependencynode_ancestor_dependency

-- Remove dependencies TopSolutionId
delete from DependencyBase where DependentComponentNodeId in (
select DependencyNodeId from DependencyNodeBase where TopSolutionId=@solutionId
)
alter table DependencyBase NOCHECK CONSTRAINT dependencynode_ancestor_dependency 
delete from DependencyNodeBase where TopSolutionId=@solutionId
alter table DependencyBase CHECK CONSTRAINT dependencynode_ancestor_dependency