Community
Showing results for 
Search instead for 
Do you mean 
Reply

getting the opportunities linked to a history

Copper Contributor
Posts: 32
Country: United_Kingdom

getting the opportunities linked to a history

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.

 

so

 

OpportunityList histopplist = hist.OpportunityList; //gets an exception

 

while

 

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.

Employee
Posts: 1,163
Country: USA

Re: getting the opportunities linked to a history

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. 

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 32
Country: United_Kingdom

Re: getting the opportunities linked to a history

yeh i kind of assumed the lack of description in the reference was indicative.
I'll try again, i've implemented a workaround with OLEDB already but it's obviously slower.
Thank you
Copper Contributor
Posts: 32
Country: United_Kingdom

Re: getting the opportunities linked to a history

yeh you're right, seems to only throw an exception when there aren't any opportunities - not ideal but workable. I could've sworn it was throwing an exception anyway earlier but i must have just confused something.
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: getting the opportunities linked to a history

Hi,

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.

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog