Answered by:
Opportunity Product fields not calculated

Question
-
I am adding line items to an opportunity via the CRM SDK. As far as I can tell, the Amount and Extended Amount fields should be calculated automatically when the line item is created, but that isn't happening for me. The record is being created, but the calculated fields are zero. I've also tried setting them explicitly, but that doesn't work either. What am I missing?
Entity LineItem = new Entity("opportunityproduct");
LineItem["opportunityid"] = new EntityReference("opportunity", oppGUID);
LineItem["isproductoverridden"] = false;
LineItem["productid"] = new EntityReference("product", productGUID);
LineItem["uomid"] = new EntityReference("product", unitGUID);
LineItem["ispriceoverridden"] = true;
LineItem["priceperunit"] = new Money(100);
LineItem["quantity"] = new decimal(1);
LineItem["manualdiscountamount"] = new Money(20);
LineItem["tax"] = new Money(10);
// This doesn't work either
//LineItem["baseamount"] = new Money(100);
//LineItem["extendedamount"] = new Money(90);
Guid LineItemGUID = crmsvc.Create(LineItem);Thanks,
Joel
- Edited by Joel Leach Thursday, July 19, 2012 5:00 PM
Thursday, July 19, 2012 4:57 PM
Answers
-
I tested your code (minus the commented out lines) and replaced out the GUIDs and it created the Opportunity Product with the calculated fields as expected. I did a retrieve on the resulting record immediately after creating it in the code and the base and extended amounts were populated.
I did some additional testing and found if you don't have a Price List item created for that item, the calculated fields result in $0. This would probably in turn mean the Opportunity record needs to be associated with a Price List.
Jason Lattimer
- Proposed as answer by JLattimerMVP, Moderator Thursday, July 19, 2012 5:48 PM
- Marked as answer by Joel Leach Thursday, July 19, 2012 6:25 PM
Thursday, July 19, 2012 5:48 PMModerator
All replies
-
I tested your code (minus the commented out lines) and replaced out the GUIDs and it created the Opportunity Product with the calculated fields as expected. I did a retrieve on the resulting record immediately after creating it in the code and the base and extended amounts were populated.
I did some additional testing and found if you don't have a Price List item created for that item, the calculated fields result in $0. This would probably in turn mean the Opportunity record needs to be associated with a Price List.
Jason Lattimer
- Proposed as answer by JLattimerMVP, Moderator Thursday, July 19, 2012 5:48 PM
- Marked as answer by Joel Leach Thursday, July 19, 2012 6:25 PM
Thursday, July 19, 2012 5:48 PMModerator -
That was it. I missed putting the price list on the opportunity. An odd result if you ask me, but fixed now. Thanks.Thursday, July 19, 2012 6:25 PM