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
WPCMSWPCMS 

Creating an If Statement in a formula field

For our vendor letters we could have a choice of 3 fax numbers and a null.

Vendor Location Vendor Fax (If Print Billing vendor = false & Contact Name is null)

Vendor Location Contact Fax (If Print Billing Vendor = false &Contact Name is not null)

Vendor Location Billing Fax (If the Print Billing Vendor =true & Billing contact is null)

Null (if print billing vendor = true and the billing contact is not null)

 

IF( Print_Billing_Vendor__c=False&& isnull(Vendor_Contact__c )=True, (Vendor_Fax__c ),
IF( Print_Billing_Vendor__c=False&& isnull(Vendor_Contact__c )=False, (Contact_Fax__c ), IF( Print_Billing_Vendor__c=True&& isnull( Billing_Vendor_Contact__c )=False, (Billing_Vendor_Fax__c ),"")))

 

All fields are text fields except the Print Billing Vendor is a check box.

 

This formula is not working even though I do not get a syntax error.

What am I missing?

 

Thank you in advance.

 

 

werewolfwerewolf

Formula field syntax is not Java syntax.  It's more like Excel.  Think Excel when you're writing this stuff.  And like Excel it uses prefix notation, not infix like you're using.

 

For example:

 

IF(
    AND (
        NOT(Print_Billing_Vendor__c),
        ISNULL(Vendor_Contact__c)
    ),
    Vendor_Fax__c,
    <Something else goes here>
)

EtienneCoutantEtienneCoutant

Can you try:

 

 

IF(AND(Print_Billing_Vendor__c=False, ISNULL(Vendor_Contact__c )), Vendor_Fax__c , IF( AND(Print_Billing_Vendor__c=False, NOT(ISNULL(Vendor_Contact__c ))), Contact_Fax__c , IF(AND( Print_Billing_Vendor__c=True,NOT(ISNULL( Billing_Vendor_Contact__c ))), Billing_Vendor_Fax__c,"&quote;")))

 

 

 

WPCMSWPCMS

Odd, the ones in color only work, the other two (black text) leave the field blank. So I entered Error in the last null and the error still won't show.

 

IF(AND(Print_Billing_Vendor__c=False, ISNULL(Vendor_Contact__c )),  Vendor_Fax__c  ,
IF( AND(Print_Billing_Vendor__c=False, NOT(ISNULL(Vendor_Contact__c ))), Contact_Fax__c ,
IF(AND( Print_Billing_Vendor__c=True,NOT(ISNULL( Billing_Vendor_Contact__c ))),
Billing_Vendor_Fax__c,
"Error")))

werewolfwerewolf
Bear in mind that ISNULL doesn't work on string fields -- you have to compare them to '' instead (like String__c='')