Showing results for 
Search instead for 
Do you mean 

Overwriting OpportunityProduct Data

Copper Contributor
Posts: 10
Country: United Kingdom

Overwriting OpportunityProduct Data

[ Edited ]
Hi all,


I need to locate an opportunity and update various information regarding the status, stage etc.

I also need to update the data that is held within the associated Opportunity Product.


I am able to update the fields within the Opportunity itself but unfortunately I am struggling to update/overwrite any fields within the associated Product.

I was hoping to do something along the lines of:


opp.Products[0].Name = "New Name";
opp.Products[0].ItemNumber = "SKU";


However many of the fields are protected and cannot be altered using normal get/set commands.


I have also looked into the Opportunity.RemoveProducts() and Opportnity.AddProduc(methods but keep receiving the error message:

"Operation is not valid due to the current state of the object."


The only solution I can see at the moment is to delete the original opportunity and re-create a duplicate (with updated values) to replace it. But this surely cannot be right!


Thanks in advance.



Message Edited by RobNightingale on 05-13-2009 07:48 AM
Copper Super Contributor
Posts: 69
Country: USA

Re: Overwriting OpportunityProduct Data

Hi Rob,


When you received the message 'Operation is not valid due to the current state of the object.' was the opportunity Open? Because when it's closed, act also disables the products in the UI. I wonder if that's the issue. 

Hugo Vale