Workflow Madness

Hi guys,

So I’ve been writing this post below, pulling my hair out trying to figure out the workflows not being sequential. And I’m still baffled, even though I believe I found the cause and perhaps the solution.

What I discovered today is that the debugger doesn’t display the data in real time: so actions have already happened by the time the debugger displays what data it searched.

My workflow is able to demonstrate that, as it actually works in spite of the data output in the debugger saying otherwise.

What I did in step 3 of option 2 below, is set the condition: only when step 1 result is empty or step 2 result is empty → my assumption is that it would need the result of both (which is not actually correct now that I think about it, because if the condition of one step is met, it has no reason to wait for the second step.

So it works but it actually doesn’t make sense… :thinking:

Original post I intended to publish:

I naively believed the workflow order was sequential (because of the arrows in a single line). Found out yesterday that it’s not and it’s completely baffling me. I just don’t get how you can do a proper workflow if the conditions are not checked first and creating a fork in the logic of the workflow.

I’ve tried passing the result of the first step into the second, but that doesn’t help either. If I have a “new thing” in the middle of previous steps, it doesn’t need the previous step’s data. And if the previous step is not meeting the condition then it’s empty, and I need the new thing regardless of true or false, I just need it to be done after my other steps are completed.

Also in a search for things, I cannot say unique ID <> the ID of the thing I just created. So I can’t exclude this item, which is really messing my my work.

What am I trying to do? I’m glad you asked.

Context: the app records passports and visas etc. keeping a history of those as well.

Option 1

  1. Submit a new visa with an active status, attached to passport.
  2. Find other visa, with active status, different visa type, but not the visa created in step 1 >> apply cancelled status.
  3. Find other visa, with active status, same visa type, but not the visa created in step 1 >> apply used status.

In step 2 and 3, I guess I have my logical fork, though it’s not really one either. This doesn’t work because I can’t tell that the visa to change shouldn’t be the visa I just created. I can’t exclude it because unique ID search condition doesn’t allow me to have anything else than =.

I tried doing this the other way around: modify old visas first and then create a new one.

Option 2

  1. Find other visa, with active status, different visa type than the type in the form, >> apply cancelled status.
  2. Find other visa, with active status, same visa type as the type in the form, >> apply used status.
  3. Submit a new visa with an active status, attached to passport.

You’d believe it would work, but then it inevitably creates the new visa in step 3 before step 2 gets there and so the passport it finds is the one in step 3. (Why on earth would steps not be sequential?)

So I tried all kinds of tricks in conditions under step 3 of option 2:

  • Madness 1: Only when the previous step is not empty (but it is if the conditions were not met, so that fails).
  • Madess 2: Only if the number of visa of the same passport with active status < 1 (believe it or not it managed to be created before step 1 even though the visa found in step 1 clearly has an active status, so there were at least one at all time and 2 up to the point of search in step 1)

Here is the case in point adding a visa of the same type and checking the visa type match in the condition (not from the search of items to change).

  1. In the condition, the search for visa’s first item should find older visas and return the oldest visa, but instead it find the very visa that’s being submitted (the newest, see the visa number as “xxxxxx”.

2.The same occurs, and in the condition it compares to itself, so there’s obviously a match.

  1. Next it creates the new visa, having met the condition that there are no active visa found. However, the visas found in step 1 and 2 were not made inactive yet.

2 Likes