OpportunityLineItem

Represents an opportunity line item, which is a member of the list of Product2 products associated with an Opportunity.

Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), update(), upsert()

Special Access Rules

The user must have the “Edit” permissions on Opportunity records in order to create or update opportunity line items on an opportunity.

Fields

Field Details
ConnectionReceivedId
Type
reference
Properties
Filter, Nillable
Description
ID of the PartnerNetworkConnection that shared this record with your organization. This field is only available if you have enabled Salesforce to Salesforce.
ConnectionSentId
Type
reference
Properties
Filter, Nillable
Description
ID of the PartnerNetworkConnection that you shared this record with. This field is only available if you have enabled Salesforce to Salesforce. Beginning with API version 15.0, the ConnectionSentId field is no longer supported. The ConnectionSentId field is still visible, but the value is null. You can use the new PartnerNetworkRecordConnection object to forward records to connections.
CurrencyIsoCode
Type
picklist
Properties
Filter, Restricted picklist
Description
Available only for organizations with the multicurrency feature enabled. Contains the ISO code for any currency allowed by the organization.
If the organization has multicurrency enabled, and a Pricebook2 is specified on the parent opportunity (that is, the Pricebook2Id field is not blank on the opportunity referenced by this object’s OpportunityId), then the value of this field must match the currency of the CurrencyIsoCode field on the PricebookEntry records that are associated with this object.
Description
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Text description of the opportunity line item. Limit: 255 characters.
Discount
Type
percent
Properties
Filter, Nillable, Sort
Description
Discount for the product as a percentage.
When updating these records:
  • If you specify Discount without specifying TotalPrice, the TotalPrice is adjusted to accommodate the new Discount value, and the UnitPrice is held constant.
  • If you specify both Discount and Quantity, you must also specify either TotalPrice or UnitPrice so the system knows which one to automatically adjust.
HasQuantitySchedule
Type
boolean
Properties
Defaulted on create, Filter, Group
Description
Read-only. Indicates whether a quantity schedule has been created for this object (true) or not (false).
HasRevenueSchedule
Type
boolean
Properties
Defaulted on create, Filter, Sort
Description
Indicates whether a revenue schedule has been created for this object (true) or not (false).
If this object has a revenue schedule, the Quantity and TotalPrice fields can’t be updated. In addition, the Quantity field can’t be updated if this object has a quantity schedule. Update requests aren’t rejected but the updated values are ignored.
HasSchedule
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
If either HasQuantitySchedule or HasRevenueSchedule is true, this field is also true.
ListPrice
Type
currency
Properties
Filter, Nillable, Sort
Description
Corresponds to the UnitPrice on the PricebookEntry that is associated with this line item, which can be in the standard pricebook or a custom pricebook. A client application can use this information to show whether the unit price (or sales price) of the line item differs from the pricebook entry list price.
Name
Type
string
Properties
Filter, Nillable, Sort
Description
The opportunity line item name (known as “Opportunity Product” in the user interface). This read-only field is available in API version 30.0 and later.
OpportunityId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Required. ID of the associated Opportunity.
PricebookEntryId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort
Description
Required. ID of the associated PricebookEntry. Exists only for those organizations that have Products enabled as a feature. You can specify values for either this field or ProductId, but not both. For this reason, both fields are declared nillable.
ProductId
Type
reference
Properties
Create, Filter, Nillable
Description
ID of the related Product record. This field is unavailable as of version 3.0 and is only provided for backward compatibility. The Product object is unavailable beginning with version 8.0. Use the PricebookEntryId field instead, specifying the ID of the PricebookEntry record.
Product2Id
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The ID of the related Product2 record. This is a read-only field available in API version 30.0 and later.

Use the PricebookEntryId field instead, specifying the ID of the PricebookEntry record.

ProductCode
Type
string
Properties
Filter, Group, Nillable, Sort
Description
This read-only field is available in API version 30.0 and later. It references the value in the ProductCode field of the related Product2 record.
Quantity
Type
double
Properties
Create, Filter, Sort, Update
Description
Read-only if this record has a quantity schedule, a revenue schedule, or both a quantity and a revenue schedule.
When updating these records:
  • If you specify Quantity without specifying the UnitPrice, the UnitPrice value will be adjusted to accommodate the new Quantity value, and the TotalPrice will be held constant.
  • If you specify both Discount and Quantity, you must also specify either TotalPrice or UnitPrice so the system can determine which one to automatically adjust.
RecalculateTotalPrice
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Changes behavior of OpportunityLineItem calculations when a line item has child schedule rows for the Quantity value. When enabled, if the rollup quantity changes, then the quantity rollup value is multiplied against the sales price to change the total price. Product2 flag must be set to true.
ServiceDate
Type
date
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Date when the product revenue will be recognized and the product quantity will be shipped. Whether this value is used by customizable forecasting depends upon the Forecast Date setting for the organization:
  • Opportunity Close Date—ServiceDate is ignored.
  • Product Date—ServiceDate is used if not null.
  • Schedule Date—ServiceDate is used if not null and there are no revenue schedules present for this line item, that is, there are no OpportunityLineItemSchedule records with a field Type value of Revenue that are children of this record.
SortOrder
Type
int
Properties
Filter, Group, Nillable, Sort
Description
Number indicating the sort order selected by the user. Client applications can use this to match the sort order in Salesforce.
Subtotal
Type
currency
Properties
Filter, Nillable
Description
Difference between standard and discounted pricing. Converted currency amounts when the opportunity's currency is different from the user's currency.
TotalPrice
Type
currency
Properties
Create, Defaulted on create, Filter, Nillable, Sort, Update
Description
This field is available only for backward compatibility. It represents the total price of the OpportunityLineItem.

If you do not specify UnitPrice, this field is required. If you specify Discount and Quantity, this field or UnitPrice is required. When updating these records, you can change either this value or the UnitPrice, but not both at the same time.

This field is nillable, but you can’t set both TotalPrice and UnitPrice to null in the same update request. To insert the TotalPrice via the API (given only a unit price and the quantity), calculate this field as the unit price multiplied by the quantity. This field is read-only if the opportunity line item has a revenue schedule. If the opportunity line item does not have a schedule or only has quantity schedule, this field can be updated.
UnitPrice
Type
currency
Properties
Create, Defaulted on create, Filter, Nillable, Sort, Update
Description
The unit price for the opportunity line item. In the Salesforce user interface, this field’s value is calculated by dividing the total price of the opportunity line item by the quantity listed for that line item. Label is Sales Price.

This field or TotalPrice is required. You can’t specify both.

If you specify Discount and Quantity, this field or TotalPrice is required.

Usage

An Opportunity can have associated OpportunityLineItem records only if the Opportunity has a Pricebook2. An OpportunityLineItem must correspond to a Product2 that is listed in the opportunity's Pricebook2. For information about inserting OpportunityLineItem for an opportunity that does not have an associated Pricebook2 or any existing line items, see Effects on Opportunities.

This object is defined only for those organizations that have products enabled as a feature. If the organization does not have the products feature, this object does note appear in the describeGlobal() call, and you can’t use describeSObjects() or query the OpportunityLineItem object.

For a visual diagram of the relationships between OpportunityLineItem and other objects, see Product and Schedule Objects.

Note
If multicurrency option has been enabled, the CurrencyIsoCode field is present. It can’t be modified, and is always set to the value of the CurrencyIsoCode of the parent Opportunity.

Effects on Opportunities

Opportunities that have associated OpportunityLineItem records are affected in the following ways:
  • Creating an OpportunityLineItem increments the Opportunity Amount value by the TotalPrice of the OpportunityLineItem. Additionally, inserting an OpportunityLineItem increments the ExpectedRevenue on the opportunity by the TotalPrice times the opportunity Probability.
  • The Opportunity Amount becomes a read-only field when the opportunity has line items. The API ignores any attempt to update this field on an opportunity with line items. Update requests are not rejected, but the updated value is ignored.
  • You can’t update the PricebookId field or the CurrencyIsoCode field on the opportunity if line items exist. The API rejects any attempt to update these fields on an opportunity with line items.
  • When you create or update an OpportunityLineItem, the API verifies that the line item corresponds to a PricebookEntry in the Pricebook2 that is associated with the opportunity. If the opportunity does not have an associated Pricebook2, the API automatically sets the pricebook on the opportunity if the line item corresponds to a PricebookEntry in an active Pricebook2, and if the PricebookEntry has a CurrencyIsoCode field that matches the CurrencyIsoCode field of the opportunity. If the Pricebook2 is not active or the CurrencyIsoCode fields do not match, an error is returned.
  • The Opportunity HasOpportunityLineItem field is set to true when an OpportunityLineItem is inserted for that Opportunity.
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.