process builder null error despite conditions - Answers - Salesforce Trailblazer Community
Ask Search:
Elad IdanElad Idan 

process builder null error despite conditions

One of my users has created a workflow that requires emails from users on a lookup field from a related object.
My solution was to create an email field on the account and populate it whenever a case is created or edited.
Since we reached the related object limit on formula fields, and our developed is too busy with high priority items to write a trigger, we have decided to create a process flow to accomplish this.

Since the use is not always populated on the related object, I've made sure to create conditions on the flow to account for any possible null values as follows:
case.customer_site__r.account_manager__r.email isnull equals false
OR case.customer_site__r.account_manager__c isnull equals false
OR case.customer_site__c. isnull equals false

Yet when I try to save a case without a relationship i get the following error:
An error occurred at element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Customer_Site__r.Account_Manager__c because it hasn't been set or assigned.

Farther, if I try to save an site with a customer site and no account manager, I get the following error:
An error occurred at element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Customer_Site__r.Account_Manager__r.Email because it hasn't been set or assigned.

It seems to me that the conditions are designed to avoid exactly these errors, but yet I am getting them. Any help with understanding this behavior will be much appreciated!
Best Answer chosen by Elad Idan
Mayank SrivastavaMayank Srivastava
Deepak's approach for using a formula field has worked well for me in the past but like you mentioned, it's not an option. 
One other think that you could try (involves creating a new hidden custom field) is have multiple nodes for catching the NULL field values.

First node criteria:
case.customer_site__c   isnull   equals   true
Immediate Action: Update hidden field to any random value

Second node criteria:
case.customer_site__r.account_manager__c   isnull   equals   true
Immediate Action:  Update hidden field to any random value

Third node criteria:
case.customer_site__r.account_manager__r.email    isnull    equals    true
Immediate Action:  Update hidden field to any random value
 
Final node criteria: Whatever is needed
Immediation Action: Update email field

I know it's a bit of a dirty hack but might get things done.

All Answers

Deepak AnandDeepak Anand
Elad,

Honestly speaking I have gone through this! The "null" checking of a Process Builder Flow is terrible. I do not know why this has been set up like this but had it been a Workflow Rule Formula or a Formula Field, this would never happen as they are more resilient to "null" / "empty" fields and handles them gracefully. In such situations, as the last resort, I would go for creating a Cross-Object Formula but in your case that has been ruled out too!

One thing I would suggest refactoring is the order. Can you put them like this:
case.customer_site__c. isnull equals false
OR case.customer_site__r.account_manager__c isnull equals false
OR case.customer_site__r.account_manager__r.email isnull equals false
This has helped me a couple of times.

See if that fixes it!
Elad IdanElad Idan
Alas, reordering the conditions did not resolve the issue.
Mayank SrivastavaMayank Srivastava
Deepak's approach for using a formula field has worked well for me in the past but like you mentioned, it's not an option. 
One other think that you could try (involves creating a new hidden custom field) is have multiple nodes for catching the NULL field values.

First node criteria:
case.customer_site__c   isnull   equals   true
Immediate Action: Update hidden field to any random value

Second node criteria:
case.customer_site__r.account_manager__c   isnull   equals   true
Immediate Action:  Update hidden field to any random value

Third node criteria:
case.customer_site__r.account_manager__r.email    isnull    equals    true
Immediate Action:  Update hidden field to any random value
 
Final node criteria: Whatever is needed
Immediation Action: Update email field

I know it's a bit of a dirty hack but might get things done.
This was selected as the best answer
Elad IdanElad Idan
That did the trick! I've created a text field and made each step populate its action so that i can track if anything went wrong - but nothing did!
Thank you!
Sam HowleSam Howle
This identical situation has been driving me crazy for months in multiple scenarios. It's very disappointing that it seems to be a Salesforce issue without a logical approach, but thank you @Mayank and @Elad for the idea on the workaround. And at minimum it's good to know I'm not the only one stuck on this!
Sam HowleSam Howle
For anybody who is wondering, I have made some progress on this. Rather than setting the hard criteria of "ISBLANK()" or "ISNULL()" etc, you could use an IF statement in the formula.

For example-
IF(NOT(ISBLANK(your field here)), <execute code here>, <false>)

I haven't tested this extensively yet, but so far on my immediate actions it's been working. In my case I'm assigning a task to a user, and the "true" result of the IF statement is what I want, and then the "false" portion is my fail-safe option. I imagine that Salesforce will process this more consistently and you can get creative to either assign an alternative field value or cancel the operation altogether. Both preferable to throwing errors. Good luck.