Devops after applying solution upgrade - part 1

 BS"D


At a  Dynamics CRM 2016 version 8.1.0.

We have applied a solution upgrade for deleting many entities.

After applying changes the next solution had many errors such as:

There should not be more than one component instance for a solution being upgraded.  Solution id: 5e69f1c5-3000-4520-853a-794a1396082c

solution With Id = faa0002a-4c98-4fdf-9f35-a0fd854a2703 Does Not Exist


The solution was to run the following SQL queries, I would pre check with a transaction to make sure I don't hit thousands of records, and I tried first in a test environment before I ran it on production.

this is unsupported, and it can be done only on an on-premise environment. Probably, if you open a ticket at Microsoft I guess they'll do the same:

declare @oldSolutionId  uniqueidentifier = 'FAA0002A-4C98-4FDF-9F35-A0FD854A2703'

declare @newSolutionId  uniqueidentifier = '5E69F1C5-3000-4520-853A-794A1396082C'


UPDATE AttributeMapBase

SET SolutionId = pa.solutionid

FROM AttributeMapBase

LEFT OUTER JOIN AttributeMapBase AS pa

ON AttributeMapBase.ParentAttributeMapId = pa.AttributeMapId

WHERE AttributeMapBase.SolutionId = @oldSolutionId



Begin Transaction

UPDATE AttributeMapBase

SET SolutionId = @newSolutionId

FROM AttributeMapBase

LEFT OUTER JOIN AttributeMapBase AS pa

ON AttributeMapBase.ParentAttributeMapId = pa.AttributeMapId

WHERE AttributeMapBase.SolutionId = @oldSolutionId

commit transaction -- Rollback transaction



Begin Transaction

UPDATE ptb

SET ptb.SolutionId = wb.solutionid

from

   ProcessTriggerBase ptb

left join WorkflowBase wb on ptb.ProcessId = wb.WorkflowId

where

ptb.solutionid= @oldSolutionId

commit transaction -- Rollback transaction



Begin Transaction


DELETE FROM ProcessTriggerBase 

where

solutionid= @newSolutionId and OverwriteTime ='1900-01-01 00:00:00.000'

and ProcessTriggerId in (

select ptb.ProcessTriggerId

from

   ProcessTriggerBase ptb

where

ptb.solutionid = @newSolutionId

group by ProcessTriggerId

having count (*) > 1

)

commit transaction -- Rollback transaction

Credits to:


 


 

Comments

Popular Posts