I want to be able to let my users invite collaborators to their company.
These collaborators status can be:
- Not having an account
- Already have an account but not be in a company
- Already have an account and already be in a company
When they do not have an account, I want to add them to the company that is sending the invitation and would send an email to reset the password.
If he already has an account but is not in any company, he would be added to the company and then send an email to access your company account.
If he already have an account and a company, I would send an email informing he about the invitation and if he would like to change companies.
This should be a simple flow. But when using the functions to create an account for someone else, I’m having problems doing these checks before the action of adding the person to the company of the user who is inviting.
For reasons of asynchronicity of the actions, I couldn’t find a way to make the conditions to be respected.
Ex:
I invite a user who does not have an account. → Account is created → The action to populate the new account with the company is triggered (even if it is inside a custom event, after all other actions) → All other actions also trigger as the user now owns a company (even if them are the first actions in the workflow and with conditionals like (only when user company is empity)) .
I’ve tried to put custom states as conditionals (set state with the user company and then use these custom states as conditional), and use Custom Events in all actions to try to do everything synchronously, and nothing.
Has anyone created a similar flow, have any ideas?