How To Fix the Duplicate Estimate Cards in the Estimates View

A fix for estimates cards that are duplicated after closing and creating a version

Issue

In Automatic Pricing version, 2022.1.01 - 2022.1.0.10, some clients were running into issues where they would create an estimate and that estimate or the Parent estimate ended up becoming duplicated like the image below.

This happened because the Parent (base estimate) and Child (versions created from the Parent) were not getting set correctly. 

Resolution 

Here are the scripts to fix this issue. This has to be run by someone that has access to the Centralised SQL server, on the DESTINIData Projects database. 

This script finds the estimates that are duplicated 

SELECT EstimateContainers.[Key]
      ,Estimates.EstimateName
      ,EstimateVersions.VersionName
      ,[EstimateKey]
      ,[VersionKey]
      ,[ParentEstimateContainer]
      ,[RootEstimateContainer]
      ,[QTOManagerKey]
  FROM [EstimateContainers]
  INNER JOIN EstimateVersions ON EstimateContainers.VersionKey = EstimateVersions.[Key]
  INNER JOIN Estimates ON EstimateContainers.EstimateKey = Estimates.[Key]
  WHERE ParentEstimateContainer is NULL
  and RootEstimateContainer is not NULL

This script fixes all the duplicated estimates 

Update EstimateContainers
Set ParentEstimateContainer = RootEstimateContainer
WHERE ParentEstimateContainer is NULL
AND
RootEstimateContainer is NOT NULL

 Here are the instructions to update these duplicated estimate cards