2

I currently created a process which checks if a parent account is present, has been changed and checks if a parent field contains a certain value. If these conditions are met, update other fields in the active account. This works however, when I try removing the parent from the active account the process fails resulting in the following error.

"An error occurred at element myDecision (FlowDecision). The flow failed to access the value for myVariable_current.Parent.referenceField__c because it hasn't been set or assigned."

The decision where the process fails is the following

AND(
    NOT(ISBLANK([Account].ParentId)),
    ISCHANGED([Account].ParentId),
    ISPICKVAL([Account].Parent.referenceField__c, "Strategic")
)

I also tried checking if that field was empty

AND(
    NOT(ISBLANK([Account].ParentId)),
    ISCHANGED([Account].ParentId),
    NOT(ISBLANK(TEXT([Account].Parent.referenceField__c))),
    ISPICKVAL([Account].Parent.referenceField__c, "Value")
)

I'd assume that the decision would result in false when ParentId is found to be empty but the system is still checking if the parent's variable has been set. Any help is appreciated!

1

From reading the phrasing of your question and then seeing your formula code, I believe I have some thoughts on how to resolve your issue.

checks if a parent account is present, has been changed and checks if a parent field contains a certain value.

Your formula below as written, doesn't do what you describe above sequentially:

AND(
    NOT(ISBLANK([Account].ParentId)),
    ISCHANGED([Account].ParentId),
    ISPICKVAL([Account].Parent.referenceField__c, "Strategic")
)

What the above does is an All or Nothing test. It's a Boolean Result. If any of the above are false, the test fails. However, unlike much of Apex, in a formula, all tests have to execute for the formula to complete. You're not first testing to see if the ParentId is ISBLANK before the code decides whether to test to see if the ParentId ISCHANGED and then decides to test if the referenceField__c picklist value is equal to "Strategic".

If that's what you want, you need to "nest" your formulas or "sequence" them by inserting decision trees in your flow with exit branches. Exactly how depends on the answer to this question: Are there different directions your flow would take if one of the above were false and the others were true?

Clearly if there's no parent, there's no Parent.referenceField__c that can be assigned to the equivalent field on the Account record your flow is working with. To me, that sounds exactly like what the error message is saying. In essence, if there's no parent, your flow can't process the record any further and you need to discard it from the list of records you've collected for further processing in your flow.

Its either that or you need to send those records at your decision tree in another direction that processes them differently than the records that pass the test. I don't know the details of your flow and it's not clear to me at what point the parentId is being removed from the record (or it's a case of needing to screen for records that may not even have a parentId).

If you're removing the parentId within your flow, you may be populating a variable with the look-up to the parentId and the related field. When the parentId disappears, you lose the context for the lookup to the related field. At that point, the flow doesn't know what to do with the orphaned field once that lookup is removed that it was using to provide that reference.

This could be a case of where you need to assign the value by reference rather than as a lookup to the parent record in order to solve the issue you're having which admittedly, is not an ideal solution. Either that, or you'd need to remove the reference to the field first before removing the look-up. I don't have enough information to guide you further, but clearly that's what it's searching for and your process needs to direct these records around that part of your code if they don't have the look-up available.

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.