[feat] sfpegMerge_CTL - Handle same SiteId for DomainSite
Is your feature request related to a problem? Please describe.
Problem:
A strange situation occured on our org where we have DomainSite records with similar SiteIds:
In the sfpegMerge_CTL we create a siteDomainMap :
List<DomainSite> domainSiteList = [SELECT DomainId, SiteId FROM DomainSite WHERE SiteId IN :siteMap.keySet()];
System.debug('getValues: domainSiteList fetched ' + domainSiteList);
Set<Id> siteIds = new Set<Id>();
Map<Id,ID> siteDomainMap = new Map<Id,ID>();
for (DomainSite iterDS : domainSiteList) { siteIds.add(iterDS.DomainId); siteDomainMap.put(iterDS.SiteId,iterDS.DomainId);}
System.debug('getValues: siteIds extracted ' + siteIds);
Since the SiteID is the key of this map, we could arbitrarily end up with a DomainSite with an empty Domain (as highlighted in the image). This causes a NullPointerException further down the line
Describe the solution you'd like A solution we would like is to filter out DomainSites with empty Domain.Domain. Suggested change:
List<DomainSite> domainSiteList = [SELECT DomainId, SiteId FROM DomainSite WHERE SiteId IN :siteMap.keySet() AND Domain.Domain != Null];
(currently line 255 as of the writing of this issue)
Describe alternatives you've considered No alternatives have been considered at this moment.
Additional context Tried to re-create this strange behaviour of having one DomainSite with similar SiteIds on a developer sanbox. Could not re-create this behaviour.
@brave-hawk Just saw your issue. Do you still have the problem ?