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
Raymond AireyRaymond Airey 

Validation Rule to stop Opportunity Create on Certain Accounts

Hi All,

We have run into a few issues lately where users of our salesforce instance are creating opporunities against accounts accounts that are 'Closed' are do not belong to us. I wont go into the reasons behind this as its quite complicated.

Bascially I'm trying to write a validation rule that will stop opportunities being created against Account numbers starting with '4' and/or accounts that are closed. These fields are currently not on the opportunity screen but do exist on the account screen.

Does anyone have any guidance as to how I can write the validation rule?
Best Answer chosen by Raymond Airey
Ajinkya1225Ajinkya1225
Ray,

Update your validation to:
OR( ISPICKVAL( Account.Customer_Status__c , 'C'), BEGINS( Account.AccountNumber , '4'))
This should solve your problem. We are using OR coz, OR is suprset of AND.

Can you take a moment to  upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh

All Answers

Ajinkya1225Ajinkya1225
Hi Raymond,

Here is the validation for checking if the account number starts with 4. There is a function- BEGINS for your rescue here!
BEGINS( Account.AccountNumber , '4')
How are you capturing if the account is closed? Is there any checkbox or picklist value? I need the api name and type of that value to add to the validation.

Please upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh
Raymond AireyRaymond Airey
Hi Ajinkya,

I really appreciate your help with this. That validation rule works 100% spot on!

We currently capture 'Account Status' using a picklist field named 'Customer_Status__c' with the options of A, C or S, with C meaning Closed.

Raymond

 
Ajinkya1225Ajinkya1225
Ray,

Update your validation to:
OR( ISPICKVAL( Account.Customer_Status__c , 'C'), BEGINS( Account.AccountNumber , '4'))
This should solve your problem. We are using OR coz, OR is suprset of AND.

Can you take a moment to  upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh
This was selected as the best answer
Raymond AireyRaymond Airey
Ajinkya,

Thank you so much for help me with this, it works perfectly.,

Thanks Again,

Raymond