function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AndyuxAndyux 

Validation rule - Opportunity without products

How would i create a field (formula?) to check if a opportunity has products that can use for validation logic:
IF
productscount>0
AND
Probability>50%
Then - error message " Must add products to the opportunity"
Best Answer chosen by Andyux
AndyuxAndyux
This is the best way!
AND(NOT(HasOpportunityLineItem), Probability>0.5)

All Answers

Amit Chaudhary 8Amit Chaudhary 8
If( productscount>0 && Probability>50% ,'Must add products to the opportunity' ,'Has product')
Let us know if this will help you
AndyuxAndyux
1) How do i get productscount
2) I am not sure how this will work all in a formula, i am setting a validation rule. Thanks!
Naresh YadavNaresh Yadav
Hi Andyux

Give it a try.

First create a Roll Up summary field on opportunity named as 'ProductsCount'.
And then use below formula.

If(Product_Count__c >0 && Probability>0.5, true,false)
Rohit K SethiRohit K Sethi
Hi Andyux,

For your requirement I thing "Amit" give right way but there is little bit change you need to create the rollup summery field of product for productsCount and apply same forumla as amit sended.

Thanks.
AndyuxAndyux
Done.
If the probability is less than .5 - nothing happens - good.
If the probability is greater than .5 - error message shows. Problems is that the error message shows even if there are products in the opp.
The "products count" roll up summary field works, shows
Products Count = 2.00 - thats is correct in this case. But the error still shows.. i am using
Validation Rule Detail
Error Condition Formula	If(Products_Count__c >0 && Probability>0.5, true,false)
thanks!




 
Naresh YadavNaresh Yadav
Hi Andyux

may be you want that when there is no products then error will come up right ?

if so then make a small change in the validation rule.

If(Products_Count__c <0 && Probability>0.5, true,false)
AndyuxAndyux
This is the best way!
AND(NOT(HasOpportunityLineItem), Probability>0.5)
This was selected as the best answer