2

I have a visual work flow on Accounts and I need to evaluate whether a field on the parent, sibling, or child accounts related to the account the flow was launched on is blank or not. I'm looking at this as a simple criteria-based lookup but evaluating all accounts related to the flow launch account in the account hierarchy. Thanks in advance.

1

Well, you've got three different issues here. Parent, sibling, and child searching all use different methods of location.

Parent. This is the easiest. ParentId is a single field on the account record, so it's as simple as doing a Record Lookup on Account, using the ParentId as the criteria. This, however, can get more complicated if you need to also evaluate "Grandparent" accounts. If this is the case, you'll have to use a loop to test upward, potentially infinitely, until a ParentId is no longer found.

Sibling. This will also involve a loop, albeit a simple one. In this case, you'll have to run a Fast Lookup, gathering into an Sobject Collection Variable all of the account records who share the same ParentId as your source record. Within the loop, you can use a Decision element to check for your desired data.

Child. Similar to sibling, you'll need a loop to gather all records whose ParentId equals the Id of the source record. This is complicated again by the possibility of "Grandchild" records, especially since instead of having to check only one record per "generation", you'll have to check the children of every child you find. More loops, more fun.

Remember! It's very important to never run any Lookup, Update, Create, or Delete elements within your loop. Always lookup your data before the loop, gathering it into variables, then use Decisions to compare data from the various variables. Always put any data alterations or data for record creations into variables which can be pushed up AFTER the loop. If you don't do this, you'll hit limits fast.

This is a very high level post, but it would take a long time to develop the whole thing here, for the purposes of discussion. Feel free to work through it with these guidelines and comment on this if you have specific questions we can help with.

1
  • 1
    Thanks so much Mark. It turns out that I don't need to check for the sibling and child records but rather just create a decision element so that if a user begins the flow on a record that doesn't have a parent, then a fault should occur. I now have a different question. I need to know how to loop through user records. Thsi VWF has a screen input element where an end user will give a value where I will compare to the existing user records. I then need to know how to then update the Account record that the flow was launched on from the User record that matches. Any help would be appreciated. Jul 18 '16 at 4:01

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.