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
KsteadKstead 

Another Validation Issue

I have written the following Validation rule; adding several different countries.  The request is if the Account Country is one of these Countries; then the Agent Sales Rep is to be required/mandatory.

 

The rule checks out ok but is not firing.  Any suggestions?

 

AND( $RecordType.Name = "BBA_Strategic_Account_Opportunity",  $RecordType.Name  = "BBA_Service_Programs", OR( BEGINS("Bangladesh",  Account_Country__c ), BEGINS("Belize",  Account_Country__c ), BEGINS("Bermuda",  Account_Country__c ), BEGINS("Bolivia",  Account_Country__c ), BEGINS("Chile",  Account_Country__c ), BEGINS("China",  Account_Country__c ), BEGINS("Costa Rica",  Account_Country__c ), BEGINS("Ecuador",  Account_Country__c ), BEGINS("El Salvador",  Account_Country__c ), BEGINS("French Guiana",  Account_Country__c ), BEGINS("Guatemala",  Account_Country__c ) , BEGINS("Guyana",  Account_Country__c ), BEGINS("Honduras",  Account_Country__c ) , BEGINS("India",  Account_Country__c ) , BEGINS("Mauritus", Account_Country__c ), BEGINS("Nepal",  Account_Country__c ), BEGINS("Nicaragua",  Account_Country__c ), BEGINS("Panama",  Account_Country__c ), BEGINS("Paraguay",  Account_Country__c ), BEGINS("Peru",  Account_Country__c ), BEGINS("Portugal",  Account_Country__c ), BEGINS("Spain",  Account_Country__c ), BEGINS("Sri Lanka",  Account_Country__c ), BEGINS("Suriname",  Account_Country__c ), BEGINS("Uruguay",  Account_Country__c ), ISBLANK( TEXT( Agent_Sales_Rep__c ))))

Steve :-/Steve :-/

Personally I would ditch the long form Coutry Names and use the ISO-3166 Alpha-2 Country Code.  But if you need Country Name you could try something like this:

 

AND(
OR(
$RecordType.Name = "BBA_Strategic_Account_Opportunity",  
$RecordType.Name  = "BBA_Service_Programs"), 
OR( 
BEGINS("Bangladesh",  Account_Country__c ), 
BEGINS("Belize",  Account_Country__c ), 
BEGINS("Bermuda", Account_Country__c ), 
BEGINS("Bolivia",  Account_Country__c ), 
BEGINS("Chile",  Account_Country__c ),
BEGINS("China",  Account_Country__c ), 
EGINS("Costa Rica",  Account_Country__c ), 
EGINS("Ecuador",  Account_Country__c ), 
BEGINS("El Salvador",  Account_Country__c ), 
BEGINS("French Guiana",  Account_Country__c ), 
BEGINS("Guatemala",  Account_Country__c ) , 
BEGINS("Guyana",  Account_Country__c ), 
BEGINS("Honduras",  Account_Country__c ) , 
BEGINS("India",  Account_Country__c ) , 
BEGINS("Mauritus", Account_Country__c ), 
BEGINS("Nepal",  Account_Country__c ), 
BEGINS("Nicaragua",  Account_Country__c ), 
BEGINS("Panama",  Account_Country__c ), 
BEGINS("Paraguay",  Account_Country__c ), 
BEGINS("Peru",  Account_Country__c ), 
BEGINS("Portugal",  Account_Country__c ), 
BEGINS("Spain",  Account_Country__c ), 
BEGINS("Sri Lanka",  Account_Country__c ), 
BEGINS("Suriname",  Account_Country__c ),
BEGINS("Uruguay",  Account_Country__c )), 
ISBLANK( TEXT( Agent_Sales_Rep__c )))

 

TrinayTrinay

Hi Kstead,

 

   The following validation rule validate the salesrep field must be required, when the account country is one of the listed countries.

 

 

AND(

         OR( 

                 BEGINS("Bangladesh",  Account_Country__c ),

                 BEGINS("Belize",  Account_Country__c ),

                 BEGINS("Bermuda",  Account_Country__c ),

                 BEGINS("Bolivia",  Account_Country__c ),

                 BEGINS("Chile",  Account_Country__c ),

                 BEGINS("China",  Account_Country__c ),

                 BEGINS("Costa Rica",  Account_Country__c ),

                 BEGINS("Ecuador",  Account_Country__c ),

                 BEGINS("El Salvador",  Account_Country__c ),

                 BEGINS("French Guiana",  Account_Country__c ),

                 BEGINS("Guatemala",  Account_Country__c ) ,

                 BEGINS("Guyana",  Account_Country__c ),

                 BEGINS("Honduras",  Account_Country__c ) ,

                 BEGINS("India",  Account_Country__c ) ,

                 BEGINS("Mauritus", Account_Country__c ),

                 BEGINS("Nepal",  Account_Country__c ),

                 BEGINS("Nicaragua",  Account_Country__c ),

                 BEGINS("Panama",  Account_Country__c ),

                 BEGINS("Paraguay",  Account_Country__c ),

                 BEGINS("Peru",  Account_Country__c ),

                 BEGINS("Portugal",  Account_Country__c ),

                 BEGINS("Spain",  Account_Country__c ),

                 BEGINS("Sri Lanka",  Account_Country__c ),

                 BEGINS("Suriname",  Account_Country__c ),

                 BEGINS("Uruguay",  Account_Country__c )

               ),ISBLANK( SalesRep__c )

        )

 

I hope this will helpful for you

KsteadKstead

Thank you for your help; still can't get it to work.  Now what I'm wondering is; our Account Country field on the Opportunity is a formula taken from our Billing Country field on the Account.  It's hidden behind the scenes.

 

Would I just be better off taking the Billing Country field?

Steve :-/Steve :-/

Okay, that makes a BIG difference...  I have to ask, why you are using a custom field on the Opportunity to display the Account.Billing Country in the first place?

KsteadKstead

Good Question Steve; and I can't give you an answer.  Just started with this org a few weeks ago and its hugely customized; so still trying to figure out why some things were done.

 

These fields in the Opp aren't viewable; but they must be driving something.

Steve :-/Steve :-/

Okay, there really isn't any good reason to copy the Account Country onto the Opportunity with a custom field, unless you heavily rely on Opportunity List Views soreted/filtered by Account Country, but even then it's kinda ass backwards. 

 

A few things I'd recommend, instead of referencing the Account_Country__c formula field on the Opportunity, use the Insert Field button in the Formula Wizard to reference the Account.BillingCountry field directly.  Also, I'd didtch the BEGINS function and use a CONTAINS instead like the example in the VR Workbook ->

https://na1.salesforce.com/help/doc/en/salesforce_useful_validation_formulas.pdf 

 

and again, get rid of long form Country Name and use the ISO 3166-A2 Country Codes