0

I have installed a managed package on my org. That managed package has an object with same API name as one of my custom objects. I have a trigger on my custom object where I query my object and assign it to a list. When I query SF runs my query on my custom object but when it comes to collection SF is using managed package object in collection and thus, I get collection store error "System.TypeException:Collection store exception adding all list to list

Map<id,SurveyInfo__c> surveyMap = new Map<id,SurveyInfo__c>([ SELECT Id,Name FROM SurveyInfo__c Limit 10]);
List<SurveyInfo__c> surveyList = new List<SurveyInfo__c>();
surveyList.addAll(surveyMap.Values());

Above code is for custom object. In query I get custom object but my lists formed are for managed object i.e. namespace.SurveyInfo

3
  • I've tried the same pattern of code in one of my orgs, and could not reproduce the error. Could you provide more of your code? Is it exactly as you have written it there? e.g. are surveyMap and surveyList declared next to each other like this, or could there be some variable scope issue? Can you run the code you posted in the Execute Anonymous window, or does it result in an error?
    – Aidan
    Dec 6, 2016 at 8:39
  • Unless you query namespace__SurveyInfo__c you'll be getting your unmanaged version of SurveyInfo__c in the situation you describe. The only way you can get to objects within the managed package is to prefix them with the namespace. How do you know that 'SF is using managed package object'? Dec 6, 2016 at 9:07
  • @Aidan Yes the code is the same as shown. I don't get an error when I run from developer console. So, basically my managed package class is executed and then a trigger is fired on custom object. And I checked this part in developer org Debug Log |Aggregations:0|SELECT Id, Name FROM SurveyInfo__c limit 10 Map<Id,gTest__SurveyInfo__c>.values() 23:00:57.835 (9359634425)|SYSTEM_METHOD_EXIT|[107]|Map<Id,gTest__SurveyInfo__c >.values() 23:00:57.835 (9359713901)|SYSTEM_METHOD_ENTRY|[107]|List<gTest__SurveyInfo__c>.addAll(Object) ` Dec 6, 2016 at 9:45

0

You must log in to answer this question.

Browse other questions tagged .