000012259 - Multiple Parent Records for a Sub-Form causes errors when Viewing/Exporting Search Results in RSA Archer

Document created by RSA Customer Support Employee on Aug 29, 2016Last modified by RSA Customer Support on Sep 25, 2017
Version 4Show Document
  • View in full screen mode

Article Content

Article Number000012259
Applies ToRSA Product Set: Archer
RSA Version/Condition: All

Fix the existence of Sub-Form records with multiple parent records that causes errors when viewing/exporting search results for non-sysadmin users
Unexpected Error in the UI when navigating from page to page in search results or exporting search results
Stack Trace from w3wp log file:

An item with the same key has already been added.

  System.ArgumentException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
  An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at ArcherTech.Kernel.DataSource.Db.ContentDataSource.GetSubformParentContentField(IEnumerable`1 subformContentIds)
at ArcherTech.Kernel.Brokers.ContentBroker.GetSubformParentContentFieldInternal(IEnumerable`1 subformContentIds)
at ArcherTech.Kernel.Utility.Permissions.SubformContentAccessCheck.GetSubformContentHierarchy(SubformContentAccessCheckData subformAccessCheckData, ExtendedSessionContext context)
at ArcherTech.Kernel.Utility.Permissions.SubformContentAccessCheck.CheckAccess(ExtendedSessionContext context, AccessCheckData data, Boolean applyContentEditPermissions)
at ArcherTech.Kernel.Utility.Permissions.SubformContentAccessCheck.InternalCheckReadAccess(ExtendedSessionContext context, AccessCheckData data)
at ArcherTech.Kernel.Utility.Permissions.ObjectAccessCheck.CheckReadAccess(ExtendedSessionContext context, AccessCheckData data)
at ArcherTech.Kernel.Brokers.AuthorizationBroker.CheckReadAccessForObjects(AccessCheckData data, ObjectType objectType)
at ArcherTech.Kernel.Brokers.ContentBroker.ApplySubformPermission(IList`1 contentIds)
at ArcherTech.Kernel.Brokers.ContentBroker.GetPermissionedContent(IList`1 contentIds, Boolean checkModulePermission, Boolean checkContentPermission)
at ArcherTech.Kernel.Brokers.ContentBroker.Get(IList`1 contentIds, IList`1 fieldIds)
at ArcherTech.Kernel.Managers.ContentManager.<>c__DisplayClassd.<Get>b__c(ExtendedSessionContext extendedSessionContext)
at ArcherTech.Kernel.Utility.ManagerHelper.WrapCode[T](ManagerEventIdentifier managerEventId, SessionContext sessionContext, ExtendedManagerMethodWrapper`1 wrapped)

ResolutionIn order to fix this data condition, we must identify the records in question through a database script.  The following script can be leveraged to identify any place where this condition exists:

IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp; 
CREATE TABLE #temp(record_id int,parentcount int)
INSERT INTO #temp(record_id,parentcount)
SELECT mc.record_id,COUNT(*) FROM tblivmodulecontent mc
JOIN tblIVContent c1 ON mc.record_id=c1.content_id
JOIN tblModule m1 ON c1.module_id=m1.module_id
WHERE m1.module_type_id=5
GROUP by mc.record_id
SELECT mt.module_name,mc.* FROM tblIVModuleContent mc
JOIN tblIVContent c ON mc.content_id=c.content_id
JOIN tblModule m ON c.module_id=m.module_id
JOIN tblModuleTranslation mt ON mt.module_id = m.module_id
WHERE mc.record_id in(select record_id FROM #temp WHERE parentcount >1)
ORDER BY mc.record_id,mc.create_date

Once you have identified the records, a determination must be made on which relationship to delete.  99% of the time this issue occurs when copying a parent record, so it's a pretty good bet that you will be deleting the relationship with the higher content ID, but ensure that is the case by viewing the records as a sysadmin in the environment.  Once you have identified the relationship to delete, run the script below with the appropriate IDs:  Always take a backup prior to running any update/delete statement

DELETE tblIVModuleContent WHERE content_id=XXXXX AND record_id=XXXXX

If it is determined that the extra parent record(s) is a duplicate that can be deleted, there is no need to run the delete statement.  You can simply delete the record from the UI.  There will be no foreign key constraint on tblIVModuleContent and the original record will retain its relationship.
Legacy Article IDa63702