08-07-2012 02:12 AM
So i'm trying to retrieve the list of opportunities that are associated with a particular history item through the SDK. There is a history.opportunitylist property that should do this in theory but I keep getting an "object reference not set to an instance of an object" exception when i try to get the list, even when the history item has opps linked to it.
Strangely, I can use the opportunitylist property to set a new association with no problems.
OpportunityList histopplist = hist.OpportunityList; //gets an exception
hist.OpportunityList = amendopplist; //works just fine
Anyone know why this is? I might have to use oledb to retrieve the links if this doesn't work since i'd like to amend the opportunity links for the history items instead of just replacing them but that would understandably be sub-optimal. Thank you.
08-07-2012 06:52 AM
I'm not sure if we should draw any conclusions from this, but OpportunityList is the only member of the History class that doesn't have a description in the code reference.
Nevertheless, in the demo database I created a new contact and added a history item to an existing opportunity and associated it with my new contact. After doing so I was able to get the OpportunityList associated with it with the property that's throwing an exception for you.
I was able to get the property to throw the exception, but only in a scenario where no opportunity was associated with the history even though the historytype was Opportunity Lost.
08-07-2012 07:16 AM
08-07-2012 08:08 AM
08-08-2012 04:56 AM
Just noticed this thread, the Opportunity Lost history is a SystemHistoryType. My feeling is that such a History is therefore not being associated to the Opportunity Entity. It could be an idea to interrgoate the HistoryType object and see if that sheds a little further light on the issue.