I’m a first-time user trying to build a SaaS app, and I’m at the point where I need to build the user management functionality.
Currently, my “sign up” workflow, which collects both User and Company information (Name, Domain):
- Creates a new user
- Logs that user in
- Creates a new Company only when [Do a search for Companies where Domain = Input Domain]:count is 0
- Sets the new User’s related company to the result of step 3 only when there’s a single company with the input domain.
Here’s the problem (which I worry is a bug):
Step 3 is somehow running (and therefore creating a new Company thing) before evaluating its only when condition… A new company is created every time a new user logs in, even if the only when condition evaluates to false, which it always does, as the company created in step 3 appears in the search for companies with the same domain within its own only when condition.
If I change the only when condition to check if the count of companies with the same name is 1, everything works as expected (aside from no user ever being able to create a company). The problem is that while that workaround does indeed stop companies with duplicate domains from being created, it also stops the first company from being created, rendering the sign-up flow useless.
I could be missing something, but this seems like a bug… I just reported a report, but I’m now looking for workarounds so I can proceed with development.
How can I create a sign-up flow that only creates Company things with unique Domain fields? Do I need to separate User creation from Company creation?