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
fishernfishern 

Validation : ISPICKLIST and a number field >0

Hi

I am having problems with validation of a value field call Credit__c

 

It must be >0 if a cerain value is selected in a picklist, ie ISPICKLIST (Transaction Type,"Credit Purchase") and must be < 0 if ISPICKLIST (Transaction Type,"Credit Purchase")

 

I have tried many different options and the validation rule just doesnt seem to fire. Both fields are in the same customer object.

 

I would appreciate some help if possible. Many Thanks

Best Answer chosen by Admin (Salesforce Developers) 
fishernfishern

Sorry, you are right

 

new code

 

OR (
AND ( ISPICKVAL(Transaction_Type__c, 'Purchase Credit'), Credit__c < 0),
AND ( ISPICKVAL(Transaction_Type__c,'Trade in Credit'), Credit__c > 0)
)

 

I also had to change the signs around <, >

 

Inteestingly enough though i can still out a zero in the field which I can onlyy assume is classed as a blank or NULL

 

Thanks very much for your help

 

 

All Answers

SatgurSatgur

Hi,

 

You may try implementing this Validation Rule using following construct -

 

OR ( AND ( ISPICKVAL(Transaction Type, 'Credit Purchase&quote'), Credit__c > 0), AND ( ISPICKVAL(Transaction Type,'Debit'), credit__c < 0) )

 

 

1. For each condition you will need to have an AND clause, since you have mentioned 2 checks I have included two AND clauses.

2. You will need to mention exact API name of the field for "Transaction Type" picklist field.

 

 

Let me know if above validation rule does address your requirement.

 

 

- Satgur

fishernfishern

Thanks so much for this. The final rule is

 

OR (
AND ( ISPICKVAL(Transaction_Type__c, 'Credit Purchase'), Credit__c > 0),
AND ( ISPICKVAL(Transaction_Type__c,'Trade in Credit'), Credit__c < 0)
)

 

 

And it didnt fire

 

record below

 

Transaction Number 00000011 Account abc Transaction Date 13/07/2009 16:25     Transaction Type Purchase Credit     Description hlhkkhkh     Credit -1

 

As youcan see purchase credit is negative and

 

Maybe I have missed something?

werewolfwerewolf

Well it says

 

Transaction Type Purchase Credit 

 

That doesn't correspond to either of the ISPICKVALs in your rules.

fishernfishern

Sorry, you are right

 

new code

 

OR (
AND ( ISPICKVAL(Transaction_Type__c, 'Purchase Credit'), Credit__c < 0),
AND ( ISPICKVAL(Transaction_Type__c,'Trade in Credit'), Credit__c > 0)
)

 

I also had to change the signs around <, >

 

Inteestingly enough though i can still out a zero in the field which I can onlyy assume is classed as a blank or NULL

 

Thanks very much for your help

 

 

This was selected as the best answer
werewolfwerewolf
The zero thing is because your rule isn't covering zero, only "more than 0" or "less than 0".  If you want it to cover zero itself you should make one of your clauses contain >=0  or <=0.