You need to sign in to do that
Don't have an account?
alexannic
BUG: Setting Sales Price not possible in OpportunityLineItem - Help needed!
Hello,
I am trying to write a small S-Control which allows the user to specify a quantity and UnitPrice (or SalesPrice) in an Opportunity Line Item.
However, when the user enters a different quantity than the current one and changes the sales price, the s-control completely ignores the specified SalesPrice. Instead, it calculates what the sales price should be with the new quantity so that the old Total Price is kept the same!
Example:
if an existing Opportunity line Item has the following values:
Quantity: 3, SalesPrice 10, and TotalPrice 30 (3x10=30)
and I change the Quantity to 2, and SalesPrice to something else, say 11.28, the values become:
Quantity: 2, SalesPrice 15, and TotalPrice 30 (2x15=30 again, instead of 2x11.28=22.56)
Here is sample source Code illustrating this behaviour:
Code:
To use the above code, replace the OpplineID variable with a valid OpportunityLineItem ID from your organisation.
Any help will be greatly appreciated, as I'm really stuck at the moment!
Thanks.
I am trying to write a small S-Control which allows the user to specify a quantity and UnitPrice (or SalesPrice) in an Opportunity Line Item.
However, when the user enters a different quantity than the current one and changes the sales price, the s-control completely ignores the specified SalesPrice. Instead, it calculates what the sales price should be with the new quantity so that the old Total Price is kept the same!
Example:
if an existing Opportunity line Item has the following values:
Quantity: 3, SalesPrice 10, and TotalPrice 30 (3x10=30)
and I change the Quantity to 2, and SalesPrice to something else, say 11.28, the values become:
Quantity: 2, SalesPrice 15, and TotalPrice 30 (2x15=30 again, instead of 2x11.28=22.56)
Here is sample source Code illustrating this behaviour:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Edit OppLine</title> <script src="/soap/ajax/8.0/connection.js" type="text/javascript"></script> <script language="javascript"> var OpplineID = "00k200000024JF4" function initPage() { sforce.connection.query("Select o.Opportunity.Id, o.Opportunity.Name, o.Id, o.ListPrice, o.Quantity, o.TotalPrice, o.UnitPrice from OpportunityLineItem o WHERE Id = '"+OpplineID+"'", { onSuccess : ReadCode, onFailure : failure }); } function ReadCode(FaseisQueryResult){ var oItems = FaseisQueryResult.getArray("records"); if (oItems.length > 0) { for (var x = 0; x < oItems.length ; x++) { var Code = oItems[x]; var ID = Code.Id; var ListPrice = Code.ListPrice; var TotalPrice = Code.TotalPrice; var Quantity = Code.Quantity; var SalesPrice = Code.UnitPrice; } } var opp = new sforce.SObject("OpportunityLineItem"); opp.id = OpplineID; opp.Quantity = "3"; opp.UnitPrice = "11.28"; //now save resulte = sforce.connection.update([opp]); window.parent.opener.location = "/"+OpplineID; window.close(); return false; } function failure(error) { alert(error); } </script> </head> <body onload="initPage();"> </body> </html>
To use the above code, replace the OpplineID variable with a valid OpportunityLineItem ID from your organisation.
Any help will be greatly appreciated, as I'm really stuck at the moment!
Thanks.
Message Edited by alexannic on 04-05-2007 04:00 AM
Sales Price $10.00
Total Price $30.00
Sales Price $11.28
Total Price $22.56
Well my code actually calculates the Sales Price minus a discount (which is stored in a custom field), but that's a simple math formula.
Good news though:
The problem is solved if I set quantity & Total Price and not quantity and SalesPrice!
I am sure this is a bug, because I certainly do not have any code in my S-control to set the Sales Price to a value which will compensate for the change in quantity so that the total stays the same! By the way, same behaviour observed in vb .net with the API.
Thanks for the help anyway..
Alex