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
PubNoahPubNoah 

Validation to not allow a field to be populated based on conditions

Hi,

I'd like to use a validation rule to say that if a certain value is selected in a pick list, a currency field MUST be left blank in order to save the case.  I have used validations before saying that if a field value is selected, a field is MANDATORY, but not the other way around.  Details below:

 

Controlling pick list:  Integration__c

Value:  "PCI"

Currency field name:  Publisher_CPM__c

 

Can you help?  Thanks so much!

Best Answer chosen by Admin (Salesforce Developers) 
User@SVFUser@SVF

PubNoah,

 

Try IF(AND(ISPICKVAL( Integration__c, "PCI"), NOT(ISNULL( Publisher_CPM__c))),TRUE,FALSE)

 

OR

 

IF(AND(ISPICKVAL( Integration__c, "PCI"), ( Publisher_CPM__c != NULL)),TRUE,FALSE)

 

Please check the syntax, as I did not validate above in salesforce. but at a higher level this is how you need to write your validation for the requirement you specified.

 

Hope it helps.

All Answers

User@SVFUser@SVF

PubNoah,

 

Try IF(AND(ISPICKVAL( Integration__c, "PCI"), NOT(ISNULL( Publisher_CPM__c))),TRUE,FALSE)

 

OR

 

IF(AND(ISPICKVAL( Integration__c, "PCI"), ( Publisher_CPM__c != NULL)),TRUE,FALSE)

 

Please check the syntax, as I did not validate above in salesforce. but at a higher level this is how you need to write your validation for the requirement you specified.

 

Hope it helps.

This was selected as the best answer
PubNoahPubNoah

Thanks, User@SVF!  That worked! (the first one)

 

One other question...  How can I make it multi-fields must be blank.  So, if PCI is selected, "Publisher_CPM__C" and "DP_CPM__C" must both be blank?

 

Sorry, new to this and still getting the hang.

 

Thanks!

User@SVFUser@SVF

PubNoah,

 

try the following.

 

IF(AND(ISPICKVAL( Integration__c, "PCI"), AND( (NOT(ISNULL( Publisher_CPM__c))), (NOT(ISNULL( Publisher_CPM__c)))) ),TRUE,FALSE)

 

- Please check the syntax.

 

*** When you go to the edit page for writing the formula, on the right hand side you will have the list of functions available for validations and also a short description will be given below, along with examples on how to used the function.

 

Thanks,

PubNoahPubNoah

I can't figure this out...  Here is what I have.  Any ideas?

 

IF(AND(ISPICKVAL(TEST_Integration__c, "PCI")), OR(ISPICKVAL(TEST_Integration__c, "PCG")), OR(ISPICKVAL(TEST_Integration__c, "PCGH")), NOT(ISNULL( Publisher_CPM__c))),TRUE,FALSE)

User@SVFUser@SVF

please post your exact requirement & field names... so that I can build your validation rule.

PubNoahPubNoah

Thanks!  Conditions below.  I keep trying to use Excel statements, and it's not working out for me.  :)

 

Controlling pick list:  Integration__c

Values, in quotes:  "PCI" "PCG" "PCGH"

Currency field names, separated by comma:  Publisher_CPM__c, DP_CPM__c

 

To sum it up, if any of those values are picked in the designated pick list, the record should not be able to be saved if there is a value in either of the noted fields.

 

Thanks!

User@SVFUser@SVF

Please try this.

 

 

IF(
	AND(
		OR(
			ISPICKVAL(Integration__c, "PCI"),
			ISPICKVAL(Integration__c, "PCG"),
			ISPICKVAL(Integration__c, "PCGH")
		),
		OR(
			(NOT(ISNULL(Publisher_CPM__c))),
			(NOT(ISNULL(DP_CPM__c)))
		)
	),
	TRUE,
	FALSE
)

 Thanks,

 

PubNoahPubNoah

Worked like a charm!