1

I am creating a visual workflow but am having trouble with a decision element. Here are my conditions:

  • Our negotiators are required to have a set list of 157 questions answered for each Opportuntiy before it is resolved.
  • Each question is created and saved as a related, child record with a given opporunity.
  • Throughout a negotiation, the majority of these questions will get raised and answered. When this happens, a record gets created.
  • Other, non-required questions (not part of the 157) can get added as records during the negotiation.
  • The names of the 157 questions/records are always the same.

I've been able to create the variables to get the data i need but I'm primarily struggling with #1 below. Whats the best way to create a decision element in this scenario? Is it a formula or picklist or something else.

  1. Use a decision element to identify which of 157 required questions/records have already been created for the opportunity
  2. Create records for the 157 questions that werent created during the negotiation
  3. Create input elements to allow a user to enter a value for the records in #2

1 Answer 1

2

It sounds like you've tried to program your way through it brute-force, like this:

  -> (True Paths)
if(q1) -> if(q2) -> if(q3) -> if(q4) -> ... -> if(q157) -> done
  V         V         V         V                 V         ^     V (False Paths)
 q1->save->q2->save->q3->save->q4->save-> ...->q157  -------^

This results in about 420 total elements, including 157 variables, 157 screens, 157 decisions, and so on. Do you really want to maintain this later? Or even now?

A much more sane way to do this would be to have a custom object store these 157 questions, which then turns in to something like this:

Load Question List  -> Load Answer List -> Start Loop on Questions -> Done
                                               V            ^
                                            Has Answer? -> Next
                                               V             ^
                                            Get Answer->save ^

This means you really have just a handful of elements (as few as 12, as I demonstrate below) instead of over 400. As a bonus, you can modify your custom object records at any time to modify how the flow works without intensive edits.

I'm not sure if I perfectly understood your question, but I built a model you can start from. Once you tinker with what I've started from, it's pretty straight-forward.

My version assumes you want the user to answer each question; if not, you can skip that step (screen) and just put whatever values you feel like in there. Keep in mind that if you're not doing things interactively, you'll want to add the answers to the list and insert them all at the end, or you risk exceeding governor limits.

Sample Question-Answer Flow

1
  • P.S. I know this flow isn't 100% correct. It's merely an attempt to point in the right direction. The main point of this answer is that a simple loop can be built to eliminate 99% or so of the elements you need to build a burdensome, unmaintainable flow. This flow also has less than a dozen variables total (one input variable, 1 collection variable, 4 sobject variables, 2 sobject collection variables, and one Dynamic Choice variable). The key to programming anything in Flow is to be efficient, so simply planning things through a bit saves time.
    – sfdcfox
    Commented Oct 15, 2016 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .