cancel
Showing results for 
Search instead for 
Did you mean: 

Set Opportunity Item Status to Won?

0 Kudos
265

Hello Experts,

I've scenario to automate the opportunity item status to WON , when the quototation item is completed. I tried the below coding its not working and throws error as attached.

Any hint what went wrong.?

Code on Item Before Save.

if (this.Status.CustomerQuoteLifeCycleStatusCode == "3")
{
	var btd = this.ToParent.BusinessTransactionDocumentReference.Where(n => n.BusinessTransactionDocumentReference.TypeCode == "72");
	if (btd.Count() > 0)
	{
		var opp = Opportunity.Retrieve(btd.GetFirst().BusinessTransactionDocumentReference.UUID);
		if (opp.IsSet())
		{
			var oppItem = opp.Item;
			//var oppItems = opp.Item.Where(n => n.PDI_OpportunityReferenceItemUUID.content == this.PDI_OpportunityReferenceItemUUID.content && n.LifeCycleStatusCode != "4" && n.LifeCycleStatusCode != "5");
			foreach (var i in oppItem)
			{
				//Logic to update the status has to be done
				//i.FinishCustomerQuoteRequestProcessing();
				i.Win();
				break;
			}
		}
	}
}

Regards,

Senthil

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Figured out, ExternalStatusCode field is responsible for status change, adjusted the code accordingly and worked.