Process Builder - Failed to Access Variable because it hasn't ben set or assigned. - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Steve DeYoungSteve DeYoung 

Process Builder - Failed to Access Variable because it hasn't ben set or assigned.

I have a process that is built on the Case - how do I bypass/let the case be created if it can't find a contact/hasn't been created? I want the case to still be created and have it ignore this whole process builder flow.

The first process looks up to the case.contact's account at a custom roll-up summary field I have (Number of Entitlements) that counts how many entitlements an account has. If that number is 0, it creates an entitlement on the account. 

The second process takes the ID from the entitlement that was created and stamps its ID in a custom field on the account.

The thrid process takes that Entitlement ID from the account and uses it in the Entitlement lookup field on the case to associate it to the case.

Sometimes I get an error that says it can't access my Number of Entitlements field on the Contacts' account (no contact to access through) and other times I get the error saying it can't access my custom field where the Entitlement ID was stamped on the account.

Below are screenshots of the my process.
Looking at the Number of Entitlements:
User-added image
Adding the Entitlement to the case:
User-added image

Any help is appreciated - been struggling with this for a few days.
Thanks.
Best Answer chosen by Steve DeYoung
Steve DeYoungSteve DeYoung
The step that checks to see if the ContactID or the AccountID needs to come FIRST in your decision point criteria. I was checking the cross object field BEFORE I was checking to see if the ContactID or AccountID was null.

In my final version, I created a new decision point in the Process, placed it at the very top (first), removed this criteria from my other decision points,  and had this check my ContactID/AccountID. If it evaluated true (no ContactID/AccountID) then it updates a dummy checkbox.

All Answers

David LittonDavid Litton
The issue is in your Criteria.  I would recommend that you add in an additional condition that checks to see if you've got a Contact associated to the Case.  This can be done by using the Contact field (Contact ID) and finding if IS NULL equals to false (which means you've got a Contact and want to proceed to your Immediate Actions).  Right now you're sending all of your cases into it, and it is erroring because there was not Contact associated.
Steve DeYoungSteve DeYoung
Thanks, David - do I use ContactID or Contact.ID? 

I've been trying this and it still wasn't working, but I'll give it a go again and see if there was something I was doing wrong.
David LittonDavid Litton
Contact.ID = the actual value.  I would go with that :), let me know if it doesn't work!
Steve DeYoungSteve DeYoung
I used Contact.id and it didn't work, still getting the "The flow failed to access the value for myVariable_current.Account.Number_of_Entitlements__c because it hasn't been set or assigned."

User-added image

Same problem I was running into previously. Any ideas?
David LittonDavid Litton
I totally told you the wrong field... my fault, I need more caffine.  It is ContactId

User-added image
Steve DeYoungSteve DeYoung
I still received the exact same error. Should I be using the AccountID rather than the ContactID since the error is citing the account.number_of_entitlements? 
David LittonDavid Litton
Yes, I am sorry, it looked like in your intial post you mentioned "The first process looks up to the case.contact's account", so I assumed that was the relationship we needed to check on.  You're right, switch it over to AccountID and give it a shot.
Steve DeYoungSteve DeYoung
Yeah - still not working. I even tried using,"AccountID does not equal GLOBAL CONSTANT $globalconstant.null" to all of my decision points. And tried the above expression using contactid instead of AccountID just in case, too.
David LittonDavid Litton
Strange... you are using AND and not OR as your operator, correct?
 
Steve DeYoungSteve DeYoung
Yes, that's correct - just double checked to be sure, too.
Steve DeYoungSteve DeYoung
The step that checks to see if the ContactID or the AccountID needs to come FIRST in your decision point criteria. I was checking the cross object field BEFORE I was checking to see if the ContactID or AccountID was null.

In my final version, I created a new decision point in the Process, placed it at the very top (first), removed this criteria from my other decision points,  and had this check my ContactID/AccountID. If it evaluated true (no ContactID/AccountID) then it updates a dummy checkbox.
This was selected as the best answer
Fergal McMenaminFergal McMenamin
Steven is correct but just another point on this, even with the additional decision point diamond I was receiving the same error.

[Event.ActivityDate]   Greater Than  [Event].Account.My_Custom_Date__c   - gave the error 

[Event].Account.My_Custom_Date__c   Less Than   [Event.ActivityDate]      - worked

Basically I think that you can only traverse relationships on the LEFT-HAND-SIDE of the argument.

That's a whole day I'll never get back!!
Hanu NaladalaHanu Naladala
Was the issue solved? How did you manage to solve the issue?
Stevie JarrellStevie Jarrell
Steven was right. To bypass it you just need to make sure the conditions are met accoridingly. If you don't have a lookup field assigned then you have to make sure that you set it to Null = FALSE first. Instead of redoing the whole flow. You can customize the logic at the bottom, making sure that you put the one you want first followed by the corrisponding numbers. 6 AND (1 AND 2 AND 3 AND 4 AND 5)