KNOWN ISSUE: Error ''Item has already been added'' when trying to set Resource Type in a CMDB or Connector Rule

Article:TECH34891  |  Created: 2007-09-18  |  Updated: 2009-02-16  |  Article URL http://www.symantec.com/docs/TECH34891
NOTE: If you are experiencing this particular known issue, we recommend that you Subscribe to receive email notification each time this article is updated. Subscribers will be the first to learn about any releases, status changes, workarounds or decisions made.
Article Type
Technical Solution


Issue



When trying to set the Resource Type within a CMDB or Connector rule, the following error may be shown:

Module: AltirisNativeHelper.dll
Source: global.asax
Description: Unhandled exception.  Type=System.ArgumentException Msg=Item has already been added.  Key in dictionary: "8b92ef99-7bac-49a0-8694-48d7558bc7ee"  Key being added: "8b92ef99-7bac-49a0-8694-48d7558bc7ee"
StackTrace=
   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at System.Collections.Hashtable.Add(Object key, Object value)
   at Altiris.NS.Connector.Web.ImportExportRule.CreateDataClassesMappingsTable(Boolean bReloadColumns, Boolean bSetSavedValues)
   at Altiris.NS.Connector.Web.ImportExportRule.CreateAllMappingControls(Boolean bReloadColumns, Boolean bSetSavedValues)
   at Altiris.NS.Connector.Web.ImportExportRule.ResourceType_Change(Object sender, EventArgs e)
   at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
   at System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
   at System.Web.UI.Page.RaiseChangedEvents()
   at System.Web.UI.Page.ProcessRequestMain()

The following Resource Types have been reported as affected by this issue, others could be affected:

Computer
Monitor
Network Printer
Office Equipment
Peripheral
Scanner


Environment



Connector Solution 6.x

Cause



This can be caused by having the Accounting Information data class directly associated to a child Resource Type and the child's Base Resource Type, Asset.

Steps to duplicate:

  1. Add a data class, not already added, to the Computer resource type
  2. Add the same data class to the Asset resource type
  3. Try creating a Connector or CMDB rule with the resource type set to computer

Solution



  1. Back up the Altiris database
  2. Run the following sql script against the Altiris database

    --Set up @ResourceTypeDataClassAssoc table variable
    DECLARE @ResourceTypeDataClassAssoc TABLE
    (
     ResourceType nvarchar(250),
     ResourceTypeGuid uniqueidentifier,
     depth bit,
     BaseResourceType nvarchar(250),
     BaseResourceTypeGuid uniqueidentifier,
     DataClass nvarchar(250),
     ResourceDataClassGuid uniqueidentifier
    )

/*
populate @ResourceTypeDataClassAssoc with data classes
associated to resource types at each level in the hierarchy
*/
INSERT INTO @ResourceTypeDataClassAssoc
SELECT i.name as ResourceType, rth.ResourceTypeGuid, rth.depth, i2.name as BaseResourceType,
 rth.BaseResourceTypeGuid, i3.name as DataClass, rtdc.ResourceDataClassGuid
FROM ResourceTypeHierarchy rth
 JOIN item i on rth.ResourceTypeGuid = i.Guid
 JOIN item i2 on rth.BaseResourceTypeGuid = i2.Guid
 JOIN ResourceTypeDataClass rtdc on rth.BaseResourceTypeGuid = rtdc.ResourceTypeGuid
 JOIN item i3 ON rtdc.ResourceDataClassGuid = i3.Guid

/*
Find resource types that have data classes associated directly, and indirectly through
any base resource type in their hierarchy, and delete them from the ResourceTypeDataClass table
*/
DELETE FROM ResourceTypeDataClass
WHERE EXISTS
(
 SELECT *
 FROM @ResourceTypeDataClassAssoc rt1
  JOIN @ResourceTypeDataClassAssoc rt2 ON rt1.ResourceTypeGuid = rt2.ResourceTypeGuid
  AND rt1.BaseResourceType != rt2.BaseResourceType
  AND rt1.ResourceDataClassGuid = rt2.ResourceDataClassGuid
 WHERE rt1.depth = 0
  AND ResourceTypeDataClass.ResourceTypeGuid = rt1.ResourceTypeGuid
  AND ResourceTypeDataClass.ResourceDataClassGuid = rt1.ResourceDataClassGuid
)


Supplemental Materials

SourceDEFECT
ValueSYD 31619
DescriptionLogged in sydd2 (Altiris - Sydney) database


Legacy ID



38174


Article URL http://www.symantec.com/docs/TECH34891


Terms of use for this information are found in Legal Notices