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
JimInSRQJimInSRQ 

date field not really blank after setting it to null

I have a custom date field to which I want to add 3 business days.
The field starts out blank on all new records and is updated via a workflow. 
If the field has a date in it, I want to add to the existing date. 
There are instances when the date will be reset to null and updated again based on another workflow.
The logic to this works fine until I put in the IF statement
To simplify my testing I created tested each of the following formulas in the field update.
 

IF( ISNULL(Pending_Next_Follow_up_Date__c ) ,TODAY()+3 , 
TODAY()- 3)
IF( ISBLANK(Pending_Next_Follow_up_Date__c ) ,TODAY()+3 , 
TODAY()- 3)
Regardless of what I do, the IF ISNULL and ISBLANK always seems to return a false and sets the date to TODAY()-3
The actual forumula is as follows, it just never works for null and I've tried both ISNULL and ISBLANK
IF( ISBLANK(Pending_Next_Follow_up_Date__c ) , 
CASE( 
MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ), 
3, TODAY()+ 2 + 3, 
4, TODAY()+ 2 + 3, 
5, TODAY()+ 2 + 3, 
6, TODAY()+ 1 + 3, 
TODAY()+ 3 
), 
CASE( 
MOD( Pending_Next_Follow_up_Date__c - DATE( 1900, 1, 7 ), 7 ), 
3, Pending_Next_Follow_up_Date__c + 2 + 3, 
4, Pending_Next_Follow_up_Date__c + 2 + 3, 
5, Pending_Next_Follow_up_Date__c + 2 + 3, 
6, Pending_Next_Follow_up_Date__c + 1 + 3, 
Pending_Next_Follow_up_Date__c + 3 
))


 

There is also the occasion where another workflow will do a field update and change the date field to null.  What I'm findin

Best Answer chosen by JimInSRQ
JimInSRQJimInSRQ

I solved this by embedding a second IF statement.  One for ISBlank and one for ISNull, as it appears that despite my doing a field update to change a date field to null, it doesn't always = null.  Final results which work...

IF( ISBLANK(Pending_Next_Follow_up_Date__c ) , 
CASE( 
MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ), 
3, TODAY()+ 2 + 3, 
4, TODAY()+ 2 + 3, 
5, TODAY()+ 2 + 3, 
6, TODAY()+ 1 + 3, 
TODAY()+ 3 
),
IF( ISNULL(Pending_Next_Follow_up_Date__c ) , 
CASE( 
MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ), 
3, TODAY()+ 2 + 3, 
4, TODAY()+ 2 + 3, 
5, TODAY()+ 2 + 3, 
6, TODAY()+ 1 + 3, 
TODAY()+ 3 
),  
CASE( 
MOD( Pending_Next_Follow_up_Date__c - DATE( 1900, 1, 7 ), 7 ), 
3, Pending_Next_Follow_up_Date__c + 2 + 3, 
4, Pending_Next_Follow_up_Date__c + 2 + 3, 
5, Pending_Next_Follow_up_Date__c + 2 + 3, 
6, Pending_Next_Follow_up_Date__c + 1 + 3, 
Pending_Next_Follow_up_Date__c + 3 
)))

All Answers

Alain CabonAlain Cabon
Hi,

"There are instances when the date will be reset to null and updated again based on another workflow."

There is no response until now for your question most likely because ISBLANK is correct so the date itself is not null ... even if you see it null at the end of the transaction.

Simultaneous execution of workflow rules and workflow actions:  
Note: Salesforce does not support or guarantee the order of execution of workflow rules.
https://help.salesforce.com/articleView?id=000212758&type=1

Salesforce gives itself the ideas for improvements in the help article above.
 
IF( ISBLANK(Pending_Next_Follow_up_Date__c ) ,TODAY()+3 , TODAY()- 3)

This test is correct for the test of a null date so the value of Pending_Next_Follow_up_Date__c is not null at the time of test itself and will be nullified afterwards by an other workflow .
JimInSRQJimInSRQ

I solved this by embedding a second IF statement.  One for ISBlank and one for ISNull, as it appears that despite my doing a field update to change a date field to null, it doesn't always = null.  Final results which work...

IF( ISBLANK(Pending_Next_Follow_up_Date__c ) , 
CASE( 
MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ), 
3, TODAY()+ 2 + 3, 
4, TODAY()+ 2 + 3, 
5, TODAY()+ 2 + 3, 
6, TODAY()+ 1 + 3, 
TODAY()+ 3 
),
IF( ISNULL(Pending_Next_Follow_up_Date__c ) , 
CASE( 
MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ), 
3, TODAY()+ 2 + 3, 
4, TODAY()+ 2 + 3, 
5, TODAY()+ 2 + 3, 
6, TODAY()+ 1 + 3, 
TODAY()+ 3 
),  
CASE( 
MOD( Pending_Next_Follow_up_Date__c - DATE( 1900, 1, 7 ), 7 ), 
3, Pending_Next_Follow_up_Date__c + 2 + 3, 
4, Pending_Next_Follow_up_Date__c + 2 + 3, 
5, Pending_Next_Follow_up_Date__c + 2 + 3, 
6, Pending_Next_Follow_up_Date__c + 1 + 3, 
Pending_Next_Follow_up_Date__c + 3 
)))
This was selected as the best answer