0

So in a custom object in process builder, I'm trying to use a formula to populate the AccountBillingCity__c in the custom object using values from Account object, standard field BillingCity.

So I use the formula :

IF(NOT(ISBLANK([obj__c].Account__c.BillingCity)) , [obj__c].Account__c.BillingCity, '<<ACCOUNT BILLING City>>')

Where I want to populate <> if the value in Account.BillingCity is null, otherwise reference the whole value into the obj__c.

But I still get emailed the process builder error :

Error element myRule_1_A1 (FlowRecordUpdate). This error occurred when the flow tried to update records: The flow failed to access the value for myVariable_current.Account__r.BillingCity because it hasn't been set or assigned.. You can look up ExceptionCode values in the SOAP API Developer Guide.

UPDATE RECORDS: myRule_1_A1 Find all obj__c records where: Id Equals {!myVariable_current.Id} (a1F0w0000000SgvEAE) Update the records’ field values. AccountBillingCity__c = {!formula_2_myRule_1_A1_4910200535} ()

Any ideas how to get around this?


UPDATE

To show where I implemented in PB

enter image description here

  • Are you positive you are not referencing [obj__c].Account__c.BillingCity anywhere else in the process builder? Maybe upstream in the criteria for action group? – Tom Dec 2 '19 at 4:33
  • yes positive. The only logic I'm doing is to reference the cross object field (Account__c.BillingCity to Obj__r.BillingCity__c). BTW ... Define Criteria for this Action Group -> No criteria—just execute the actions! – compski Dec 2 '19 at 5:36
  • Can you check critical update "Check for Null Record Variables or Null Values of Lookup Relationship Fields in Process and Flow Formulas" . If you activate it, you can avoid null not check errors. – Ankuli Dec 3 '19 at 6:24
2

You need to take advantage of short-circuit evaluation to check for a null relationship earlier in the evaluation of the expression than the traversal of the relationship.

I wrote an article about how this works several years ago. Here's a quick summary of how it works in Process Builder.

Dereferencing a null field in a Process Builder condition or formula always results in an exception. Fortunately, Boolean operators and functions (AND and OR, including the implicit logical operations used in condition-based triggers) in the Process Builder context perform short-circuit evaluation. In other words, references across the lookup relationship can be guarded by checks against null lookups earlier in the evaluation order such that evaluation will stop before reaching the cross-object relationship, avoiding an exception. The evaluation order is left-to-right for the AND() and OR() functions and the && and || operators, and top-to-bottom for condition lists.

To apply this to your example,

IF(NOT(ISBLANK([obj__c].Account__c.BillingCity)) , 
      [obj__c].Account__c.BillingCity,
       '<<ACCOUNT BILLING City>>')

would become

IF(
    AND(
        NOT(ISBLANK([obj__c].Account__c)),
        NOT(ISBLANK([obj__c].Account__c.BillingCity))
    ), 
    [obj__c].Account__c.BillingCity,
    '<<ACCOUNT BILLING City>>'
)

The NOT(ISBLANK([obj__c].Account__c)) clause gets evaluated first, so if the relationship is null, it won't evaluate the cross-object reference.

| improve this answer | |
  • For my case, the Account object will always be populated in that object. It's just that most of the time we don't have data on their BillingAddress aggregate field - not sure if this still applied. But I'll check it out now thx! – compski Dec 2 '19 at 2:30
  • Unfortunately, your formula I used results in the same error. I have updated my question in case you misunderstood what I wanted to do. – compski Dec 2 '19 at 2:44
  • 1
    @compski I think I understand what you want to do but I'm skeptical of how this error comes about. I don't think that message should be shown if BillingCity is null. That would be quite legal. That message typically means you're traversing a null relationship field. – David Reed Dec 2 '19 at 4:46
  • Suddenly your comment gave me Eureka moment. In the same Process builder, I also update the obj__r.Account__c from the Opportunity__r.Accountid__c. So upon creation it will always detect the Account is null before it gets a chance to pull the BillingCity. Sorry about that. – compski Dec 2 '19 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.