1

I have a below scenario for opportunity object.

Criteria:

  1. When Amount is blank or 0
  2. When no Lines are available (opportunity Line)
  3. Record type is ERP Upload
  4. Stage is "Sales Order"

If above all met the criteria then update Stage to Cancel.

Now i have write below rule -

IF( Amount=0 && ISPICKVAL( StageName , 'Sales Order') && RecordType.DeveloperName = 'Non Finance', true, false)

How to check if there is no opportunity Lines are available using Workflow Rule?

3

Use field "HasOpportunityLineItem" on opportunity in your workflow. This field indicates is there any child product is added or not.

The field HasOpportunityLineItem is a standard field, not visible in the UI which is automatically calculated by Salesforce. As the documentation states:

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. An opportunity can have opportunity line items only if the opportunity has a price book. The opportunity line items must correspond to PricebookEntry objects that are listed in the opportunity 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 API returns an error. You can’t 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.

0

You can create one rollup sumary field on opportunity to count product associated with the opportunity by following the below steps:-

  1. Click Setup
  2. Click Customize | Select "Opportunity"
  3. DataType - Rollup field
  4. Object to Summarize: Opportunity Product
  5. Summary Type: COUNT
  6. Filter Criteria: All records should be included in the calculation(If you have any specific criteria, you may select "Only records meeting certain criteria should be included in the calculation")

The above field will give you a count of Products related to an Opportunity.

You can use this field in your workflow to check the lineitem on an opportunity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.