sforce logo

Opportunity


Represents an opportunity, which is a sale or pending deal.

Supported API Calls

create, update, delete, query, search, getDeleted, getUpdated, retrieve, describeSObject

Fields

For a complete list of fields in this object, see the Enterprise WSDL file for your organization and the salesforce.com online help.

StageName Field

The StageName field controls several other fields on an Opportunity. Each of the fields can be directly set or implied by changing the StageName field. In addition, the StageName field is a picklist, so it has additional members in the describeSObject response to indicate how it affects the other fields. To obtain the stage name values in the picklist, a client application can invoke the query call on the OpportunityStage object. If the StageName is updated, then the ForecastCategory is automatically updated based on the stage-category mapping.

ForecastCategory

ForecastCategory is a restricted picklist field. It is implied, but not directly controlled, by the StageName field. You can override this field to a different value than is implied by the StageName.

The values of the ForecastCategory field are fixed enumerated values. The field labels are localized to the language of the user performing the operation, if localized versions of those labels are available for that language in the salesforce.com user interface.

IsClosed and IsWon Flags

The IsClosed and IsWon flags are directly controlled by the StageName. You can query and filter on these fields, but you cannot directly set them in a create or update request. Instead, you must set the StageName to a value that has the appropriate IsClosed and IsWon flags.

Probability Field

The Opportunity Probability field is implied, but not directly controlled, by the StageName field. You can override this field to a different value than what is implied by the StageName.

ExpectedRevenue Field

The ExpectedRevenue field is a read-only field that is equal to the product of the Opportunity Amount field and the Probability. You cannot directly set the ExpectedRevenue field, but you can indirectly set it by setting the Amount or Probability fields.

Amount Field

The Opportunity Amount field is normally a regular field, but it becomes implicitly read-only if the Opportunity has any line items. Any attempt to update the Amount of an Opportunity that has line items will be ignored. The update call will not be rejected, and other fields will be updated as specified, but the Amount will be unchanged.

CampaignId Field

The Opportunity CampaignId field is a cross-reference field that points to a Campaign object. The CampaignId field is defined only for those organizations that have Campaigns enabled as a feature. The User must have read access rights to the cross-referenced Campaign object in order to create or update that campaign into the CampaignId field on the Opportunity.

HasOpportunityLineItem Field

The Opportunity HasOpportunityLineItem field is a read-only field that indicates whether the Opportunity has associated line items. A value of True means that Opportunity line items have been created for the Opportunity.

Pricebook2Id and PricebookId Fields

The Opportunity Pricebook2Id field is a cross-reference field that points to a Pricebook2 object. The Pricebook2Id field indicates which Pricebook2 applies to this specific Opportunity. The Pricebook2Id field is defined only for those organizations that have Products enabled as a feature.

The PricebookId field, like the Pricebook [Deprecated] object, has been deprecated as of version 3.0 and is provided for backward compatibility only. Unless you need to continue referring to a Pricebook [Deprecated] object for this Opportunity in an existing client application, use the Pricebook2Id field instead, specifying the ID of the Pricebook2 object.

:: Note

You can specify values for only one field (Pricebook2Id or PricebookId)-not both fields. For this reason, both fields are declared nillable.

An Opportunity can only have Opportunity line items if the Opportunity has a price book. The opportunity line items must correspond to PricebookEntrys that are listed in the Opportunity's Pricebook2. However, you can insert Opportunity line items on an Opportunity that does not have an associated Pricebook2. For the first Opportunity line item that you insert on an Opportunity without a Pricebook2, the API automatically sets the Pricebook2Id field, if the Opportunity line item corresponds to a PricebookEntry in an active Pricebook2 that 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, then the sforce Web service returns an error.

You cannot update the Pricebook2Id or PricebookId fields if opportunity line items exist on the Opportunity. You must delete the line items before attempting to update the PricebookId field.

Currency Field

The CurrencyISOCode field exists only for multi-currency organizations. If the organization does not have the multi-currency feature enabled, the CurrencyISOCode field is not accessible.

If the organization is multi-currency and a Pricebook2 is specified on the Opportunity (i.e., the PricebookId field is not blank), then the currency value of the CurrencyISOCode field must match the currency of the PricebookEntry objects that are associated with any opportunity line items it has.

Usage

Use the Opportunity object to manage information about a sale or pending deal. To update an Opportunity, your client application needs "Edit" permission on Opportunities. Client applications can create, update, delete, and query Attachments associated with an opportunity via the sforce API. For a visual diagram of the relationships between Opportunity and other sforce objects, see Product and Schedule Objects.

Client applications can also create or update Opportunity objects by converting a Lead via the convertLead call..

See Also

OpportunityCompetitor

OpportunityHistory

OpportunityLineItem

OpportunityLineItemSchedule

Concepts


© Copyright 2000-2003 SalesForce.com, Inc.
All rights reserved • Various trademarks held by their respective owners.