[SalesForce] Can’t evaluate null number in formula field

I'm trying to make a Date Formula field that display the next month in my record.

I got the object EntryLine__c where I display the year and month of my entry line.

Here is my formula :

IF(ISNULL(Year__c) || ISNULL(Month__c),
DATE(YEAR(TODAY()),1,1),
IF(Month__c = 12, DATE(Year__c + 1, 1, 1),
DATE(Year__c, Month__c+1, 1)))

Year__c and Month__c are Numbers field. I'm testing if they are null because I don't want to have a null value in my formula. I'm using it in a time trigger and if it's null it will abort my Process Builder.

I tried with ISBLANK and ISNULL functions but it doesn't work. They're still evaluated to False even if my fields are empty. So I don't understand why it doesn't work.

Best Answer

You have two options

1) Make sure that you have configured the formula correctly and that in the section Blank Field Handling, you have selected Treat blank fields as blanks (it defaults to Treat blank fields as zeroes, which basically means that when a null / blank is found, a zero is assumed instead)

2) Check for zero in your formula (option 1 is preferred)

Related Topic