There should only be at most one instance of RibbonCustomization per solution per entity. Current entity: [entityName]. Current solution: [guid]
Pois bem, muito provavelmente o metadados de Ribbons do seu CRM está, digamos, corrompido! São vários os motivos para que isto possa ter ocorrido, como por exemplo, em uma migração de versão.
Como se corrige isto, então? Atue no metadados de Ribbons, eliminando as duplicidades.
A Procedure abaixo faz justamente isto, para todas as entidades do banco do CRM.
declare @tables table (id int identity, name nvarchar(100))
declare @count int, @currentTable nvarchar(100), @sql nvarchar(max)
declare @RibbonCustomizationId uniqueidentifier,
@RibbonCustomizationUniqueId uniqueidentifier,
@Entity nvarchar(100),
@SolutionId uniqueidentifier,
@SupportingSolutionId uniqueidentifier,
@ComponentState int,
@OverwriteTime datetime,
@OrganizationId uniqueidentifier,
@PublishedOn datetime,
@IsManaged bit
-- BUSCA TODAS AS TABELAS DO CRM
insert into @tables (name)
select name
from sysobjects
where type = 'v'
order by name
-- LOOP NAS TABELAS
select @count = count(*) from @tables
while (@count > 0)
begin
select @currentTable = name from @tables where id = @count
-- CRIA UMA TEMP TABLE PARA GUARDAR OS RIBBONS AGRUPADOS POR [SolutionId]
declare @Unique_RibbonCustomization table (
RibbonCustomizationId uniqueidentifier,
RibbonCustomizationUniqueId uniqueidentifier,
Entity nvarchar(100),
SolutionId uniqueidentifier,
SupportingSolutionId uniqueidentifier,
ComponentState int,
OverwriteTime datetime,
OrganizationId uniqueidentifier,
PublishedOn datetime,
IsManaged bit)
insert into @Unique_RibbonCustomization
select RibbonCustomizationId, RibbonCustomizationUniqueId, Entity, SolutionId, SupportingSolutionId, ComponentState, OverwriteTime, OrganizationId, PublishedOn, IsManaged
from (
select *,
row_number() over (partition by SolutionId order by SolutionId) as row_number
from RibbonCustomization
where entity = @currentTable
) as r
where row_number = 1
-- GUARDA OS IDS (RibbonCustomizationId) QUE POSSUEM DUPLICIDADE DE RIBBON
declare @Diff_RibbonCustomization table (RibbonCustomizationId uniqueidentifier)
insert into @Diff_RibbonCustomization
select RibbonCustomizationId
from RibbonCustomization
where entity = @currentTable and
RibbonCustomizationId not in (select RibbonCustomizationId from @Unique_RibbonCustomization)
if (exists(select * from @Diff_RibbonCustomization))
begin
print 'Correcting EntityRibbon for: ' + @currentTable + '...'
-- EXCLUIR OS RIBBONS DUPLICADOS PARA A ENTIDADE DO LOOP
delete from RibbonCustomization
where Entity = @currentTable and
RibbonCustomizationId in (select RibbonCustomizationId from @Diff_RibbonCustomization)
-- EXCLUI AS DEPENDÊNCIAS (SolutionComponentBase, dependencybase e DependencyNodeBase)
delete from SolutionComponentBase where ObjectId in (select RibbonCustomizationId from @Diff_RibbonCustomization)
delete db from dependencybase db
inner join dependencynodebase dnb
on db.dependentcomponentnodeid = dnb.dependencynodeid or
db.RequiredComponentNodeId = dnb.dependencynodeid
where dnb.ObjectId in (select RibbonCustomizationId from @Diff_RibbonCustomization)
delete from DependencyNodeBase where ObjectId in (select RibbonCustomizationId from @Diff_RibbonCustomization)
end
select @count = @count - 1, @currentTable = null
end
print 'Done.'
Após rodar a proc você conseguirá importar sua solução sem problemas - espero! :)
[]s
Valeu!
ResponderExcluirFuncionou certinho comigo.
Tks!