Forum Academy Marketplace Showcase Pricing Features

Conditional for Creating a Thing Not Working

I have a simple workflow to create a thing only when it doesn’t already exist. When running through the debugger you can clearly see that the condition evaluates to false. (Only when search for:count is 0; count shows as 1). Even though the condition is false, it creates a new record anyway.

There is only 1 workflow associated with the button click, and only one action in the workflow, so there’s no further execution after this that could be causing this behavior.

Has anyone else seen this?

Because there is no other action that depends on this creation, by the time you look at it in the debugger, the server has already done the condition, found zero count, and done the creation.

1 Like

That’s not what your condition evaluates. Not to be pedantic, but your condition checks for if there are ANY NUMBER OF THINGS OF THIS TYPE that exist in the database.

You might be playing fast and loose with nomenclature here, but note that computers do not do that.

Hi mishav,

There is already a record in the database that meets the condition before this workflow is executed. I looked at the record that it is finding and you’re right! It’s finding the one that it just created. So my question is what’s the point of “Only When” if the execution happens before the evaluation of the condition?

Then its highly likely that the condition doesn’t match the previous record, as @keith suggests.

When you press the button again, do you get a second record created, and count going to 2?

The debugger is limited in what it is showing, it hides the fact that the workflow is (potentially) being run in two places, client and server.

Thanks for the quick responses! So what’s even more confusing is that it doesn’t create another record after subsequent runs, but the condition is doing a search for one field (which is a thing), and you can see in the screenshot that the two records are referencing the same thing. Is it possible that it’s the nested searches that are failing to find the record? If that was the case wouldn’t it create a 3rd and 4th record?


Try testing the condition by copying it, and pasting into a text element dynamic expression.

The screenshot probably shows a field that links to another data table, perhaps the search criteria isn’t quite right?

1 Like

Thanks for the suggestion. It’s confirmed that it’s not returning anything. The search criteria is right, and when I isolate the searches they work, just not in conjunction. So I think there’s an issue with the nested search, trying to find the record based on the linked field. At any rate, I’m going to try and rethink the approach. I appreciate your help on this!

1 Like

just came across the highlighted issue while trying to create a new thing, workaround that worked for me,

  1. Make changes to a thing (**filter it such that it results to one row/thing : so that it wont update the row if it does’nt find **) without applying any condition.
  2. Create a new thing (although creates a new thing , if even when the condition is false for me as well , but this condition will help in the second time i.e wont create a new row/thing as it evaluates to false)

PS: the above solution worked for me , try this out and let me know as well if there are any flaws in this approach

Hi cchopra, can you elaborate a little more on your solution, I’m having the same problem and for the life of me I can’t find a way out. I need to create a new record whenever a value stored in a cookie is empty. The condition for the thing creation is that the cookie is empty (using a plugin). When I run it in the debugger, the condition seems to be false (cookie is not empty) but the thing is still created. I’ve added all sorts of conditions that I know are false and the thing is still created. I don’t know how to condition the creation of the thing if every time it disregards the condition and still creates the thing. I’m going nuts.