+ Start a Discussion
3 Creeks3 Creeks 

Issues referencing parent record information in Process Builder criteria

I am seeing some issue with Process Builder and I just spent a lot of time testing it for a project that I am working on.  I am making this post for a couple reasons. First someone else my benefit from the time I spent testing and second, someone may have figured out what I have not been able to.  The project involves using information from a Contact associated with a Case to use as input to an invocable Apex method when the Case's Status is changed to 'Closed.'  Although this specific example deals with a parent record of the case object, I assume that the issues that I am seeing would be the same with any parent child relationship.

The Process Builder flow will consist of a simple set of criteria to determine if the case status has been changed and if the new status is closed.  If that criteria is met, the flow action will then use information from the associated contact record.

The issue does not seem to be with my Apex classes or invocable methods as I have been able to replicate the issue even when not calling any Apex.  To test Process Builder, I created a simple process that copies the associated Contact's email address to the Description field on the Case when the case status is changed to Closed.

The first thing that seems odd to me about Process Builder is that there are two ways to reference fields of associated parent records:

The first gives you a reference like this [Case].ContactEmail.  
User-added image

The second give your a reference like this [Case].Contact.Email.
User-added image

I tested both of these ways of referencing the parent field and neither one of them seems to work completely.  

My testing scenarios tested with three types of cases:
Scenario 1: Cases where there was a contact associated with it and the email field of the contact had an email address in it.
Scenario 2: Cases where there was a contact associated with it but the email field on the contact was blank
Scenario 3: Case that had no contact associted with them

With the Process Builder flow activated and for each of the above three scanrios, I test to see if the following worked correctly.
1. Can you successfully save a new scenario 1, 2 and 3 case with no flow errors.
2. When manually changing that status of a single case to 'Closed', will the flow trigger when it should and not trigger when it should not without any flow errors
3. When performing a bulk change (I used Data Loader) to change case statuses to Closed, will the flow trigger when it should and not trigger when it should not without any flow errors.

The Process Builder criteria was as follows:

Field                                                                     Operator             Type             Value
(One of the two ways to reference Contact email)     IS NULL             BOOLEAN     FALSE     AND
[Case].Status                                                        IS CHANGED     BOOLEAN     TRUE      AND
[Case].Status                                                        EQUALS             PICKLIST     CLOSED

Here are the results of my testing:

Process Builder Criteria = [Case].Contact.Email AND Flow Action using [Case].Contact.Email    
    Scenario 1: Contact is associated with Case and contact email address is filled in:
        Can save new Case? Yes
        Single manual status change: Success - Contact's email address copied to case description field
        Bulk status change: Success - Contact's email address copied to case description field
    Scenario 2: Contact is associated with Case, but email address is null:
        Can save new Case? Yes
        Single manual status change: Failed - Flow error received
        Bulk status change: Failed - Flow error received
    Scenario 3: No Contact associated with case:
        Can save new Case? No - Flow error received
        Single manual status change: Failed - Flow error received
        Bulk status change: Failed - Flow error received 

Process Builder Criteria = [Case].ContactEmail AND Flow Action using [Case].ContactEmail
    Scenario 1: Contact is associated with Case and contact email address is filled in:
        Can save new Case? Yes
        Single manual status change:  Success - Contact's email address copied to case description field
        Bulk status change: Failed - Workflow did not fire. Email NOT copied to Case Description field, but no flow error
    Scenario 2: Contact is associated with Case, but email address is null:
        Can save new Case? Yes
        Single manual status change: No Flow Error Message
        Bulk status change:  No Flow Error Message
    Scenario 3: No Contact associated with case:
        Can save new Case? Yes
        Single manual status change: No Flow Error Message    
        Bulk status change: No Flow Error Message

I also tested the criteria where there was an additional criteria line that tested if [Case].contactId was not null but got flow errors and tested criteria with the following formula criteria:

NOT(ISNULL([Case].Contact.Id)) && 
NOT(ISNULL([Case].ContactEmail)) &&
ISPICKVAL([Case].Status, 'Closed')  &&
PRIORVALUE([Case].Status)  <> 'Closed'

and that did not work either.

So, based on my testing, you cannot ever use  [Case].Contact.Email because the user will get flow errors.  Using  [Case].ContactEmail works, but users must know that bulk updates will not trigger flows.  Has anyone else come up with a completely working set of criteria for this type of scenario?

I checked known issues for process builder and did not see anything that matched the situation.

Thanks
fifedog15fifedog15
Nice write up... don't have a solution but we've run into issues when trying to use a parent field in the PB critera as well.  In our case it was looking at a currency field, which always returned zero.  We never received errors but couldn't get the process to look at the parent field.  However that all said and done.. we opened a case with salesforce... and then when they looked at it a couple days later, it worked.  And they said there where no patches release during that time.  very odd but there is still some wonky stuff I think with PB.