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
nickfs92840nickfs92840 

Validation Rule where 1 or more is required

Have a field name: Number of Facilities

API Name: Number_of_Facilities__c

 

The field is currently set to required, so user must enter a value. 

 

However, I don't want a user to enter 0, as I would want a value greater than 1 to be entered in this field. 

 

This is my current validation rule, but if I enter 0 in the field, the records still saves:

 

 

AND(ISNULL(Number_of_Facilities__c), (Number_of_Facilities__c < 0.01))

 

 

 

Can someone look at my validation rule and see where I am wrong? 

 

Thanks!!!!!

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

my bad, here you go

 

OR(ISBLANK(Number_of_Facilities__c), Number_of_Facilities__c < 1)

 

 

 

 

All Answers

Steve :-/Steve :-/

Try this

 

Number_of_Facilities__c < 1

 

 

nickfs92840nickfs92840

Hi Stevemo, 

 

It didn't work. I entered 0 and I was able to save the record. :smileysad:

Steve :-/Steve :-/

my bad, here you go

 

OR(ISBLANK(Number_of_Facilities__c), Number_of_Facilities__c < 1)

 

 

 

 

This was selected as the best answer
nickfs92840nickfs92840

Hi Stevemo, 

 

That one didn't work either. I had tried that combination at one time too. Can it be something else I have set incorrectly?

 

Steve :-/Steve :-/

Really?  I just tested it on my DE Org and it worked.  What is the datatype of the number field that you are trying to evaluate, does it have any decimals?

nickfs92840nickfs92840

has no decimals

Steve :-/Steve :-/

I think your Default Value 1 is what's messing you up, clear that out and give it a shot

nickfs92840nickfs92840

I removed the default value and also the requirement and still nothing. :smileysad:

Steve :-/Steve :-/

Just to make sure that I understand, you want the user to enter a value of 1 or greater in the field?  Can you post the exact VR Formula that you are using?

nickfs92840nickfs92840

Yes, enter 1 or equal of 1 or great than 1...so, user can enter 1 or anything greater than 1

 

This is the exact VR code entered:

 

 

OR(ISBLANK(Number_of_Facilities__c), Number_of_Facilities__c < 1)

 

And here is a screenshot of the VR window: http://www.harmonynewtechnologies.com/salesforce/ndhce/ndhc02.png

 

 

Steve :-/Steve :-/

Hi Nick,

 

I can't recreate the problem on my DE Org, can you post a screenshot of a record that should be triggering the VR, but is not?  

 

Also, I notice in the description of your VR you're saying that the user must enter a value GREATER than one, but in your earlier post you said that then number must be AT LEAST 1.  Which one is correct? 

nickfs92840nickfs92840

Hey Stevemo

Yes, the user can enter 1 or anything greater than 1. The default is 1 But if you enter 0, the record still saves.

 

 

There is no other trigger but here is screenshot of the fields on the object (blurred out the field names)

 

http://www.harmonynewtechnologies.com/salesforce/ndhce/hdce03.png

nickfs92840nickfs92840

Steve!

 

I figured it out!

 

Your formula 

 

OR(ISBLANK(Number_of_Facilities__c), Number_of_Facilities__c < 1)

 was always correct! :)

 

Thank you once again!!

 

 

goabhigogoabhigo

I have a doubt.

If the field is mandatory in page layout or field level, why ISBLANK(Number_of_Facilities__c) is used in the validation rule?

Its irrelevant right?

nickfs92840nickfs92840

@abhi_the1

 

you are right, the requirement is not required for this formula to work. Upon removing the requirements for the "number of facilities" and noticing there were numerous requirements on the object itself, the other required fields were populated with data, and the "Number of Facilities" was left  blank or with a 0, the validation rule did work and produced an error.

 

Stevemo's VR formula is correct regardless.