+ Start a Discussion
EdithEdith 

New opportunity validation rule

Hi,

 

I created this validation rule on the opportunity to prevent users creating new opps if the account has not passed credit checked. (one of the business rules)

 

AND(ISNEW(),
true, Account.Credit_Check_Passed__c = false)

 

It works fine but when converting a lead, this rule prevents from converting.  The "Do not create a new opportunity upon conversion" box is checked by default, and when unckecking it, the validation rule prevents conversion. 

 

I have been trying to add: AND (ISNEW(), Accountid...... with no luck. How can I make sure that this validation rule only applied when the acocunt is not new. 

 

Thank you

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Steve MolisSteve Molis

Hi Edit I think if you create a custom field in the Lead and Opportunty (like a checkbox) with default values set to

Lead.Checkbox = TRUE

Opportunity.Checkbox = FALSE

Then map the Lead.Checkbox to the Opportunity.Checkbox and add the field to your VR you should be all set.

 

AND(ISNEW()),
Checkbox = FALSE,
Account.Credit_Check_Passed__c = FALSE)

 In this scenario if the Opportunity comes from a converted Lead the checkbox the VR is ignored, but if the Opportuniuty come from an Account the VR is invoked.

All Answers

SF7SF7

Try This

 

AND(Not(ISNEW()),
 Account.Credit_Check_Passed__c = false)

EdithEdith

Thanks,

 

The good news is that I can convert a lead...


However it doesn't work when I create an opportunity from the account (ie. I can still create an opportunity even if the account has not passed credit check).

 

Thanks

SF7SF7

How can I make sure that this validation rule only applied when the acocunt is not new. Sorry i got this wrong i thought When Opportunity is not new

Steve MolisSteve Molis

Hi Edith,

 

Can you post the VR you're using on the Opportunity?

Andy BoettcherAndy Boettcher

Isn't your validation rule performing exactly as desired?  You don't want an opportunity created if the Lead hasn't passed a credit check, and you can convert if you don't have it create an opportunity on conversion.

 

-Andy

EdithEdith

Hi guys,

 

 

Sorry for the confusion if I have missed a bit in the explanation.

 

On the account, a field called: Account.Credit_Check_Passed__c which must be true for an opportunity to be created.

 

When a lead is converted and creates a NEW account, the rule should be ignored as at that stage the credit check hasn't been done.

 

When an opportunity is created from an existing account, the rule should fire when the Account.Credit_Check_Passed__c is false.

 

@Stevemo, this is the rule I'm using: 

AND(Not(ISNEW()),
Account.Credit_Check_Passed__c = false)

 

It lets me convert the lead as I have defaulted the "do not create an opportunity upon conversion" to true. But when I create an opportunity from that new account (and credit check=false), it doesn't stop me from doing it. How can I reference the account as being not new in this? 

 

Thanks!

 

 

 

Steve MolisSteve Molis

Hi Edit I think if you create a custom field in the Lead and Opportunty (like a checkbox) with default values set to

Lead.Checkbox = TRUE

Opportunity.Checkbox = FALSE

Then map the Lead.Checkbox to the Opportunity.Checkbox and add the field to your VR you should be all set.

 

AND(ISNEW()),
Checkbox = FALSE,
Account.Credit_Check_Passed__c = FALSE)

 In this scenario if the Opportunity comes from a converted Lead the checkbox the VR is ignored, but if the Opportuniuty come from an Account the VR is invoked.

This was selected as the best answer
EdithEdith

Hi SteveMo,

Thanks a lot for this, it did the trick, perfect! :)

Edith 

Steve MolisSteve Molis

No problem, you owe me a beer! 

 

And I drink THESE!  http://beeradvocate.com/beer/profile/863/7971