How to search for all users from backend workflow?

Hi all,

Does anyone know how I can search for all users?

I have a backend workflow which triggers a notification, which works fine. I need all users (with matching company) to get the notification but Search for Users is asking me for more info?

To Search for ALL Users just do a search for Users.

What more info is it asking for? (I’m guessing your Recipient field is a User, not a list of Users, so it will be asking you to specify which user will be the Recipient)…

If I understand correctly what you’re trying to do you’ll need to run the workflow on a List of Users not just a single User.

1 Like

What you’ll need to do is to run a workflow in the back-end. For each user, you’ll want to trigger a notification. The list of Users has to match the criteria for them to receive the notification. Small example below.

To summarize the screenshots, you keep scheduling the api until the Count is equal to the Users count. Each user in this case, has a new offer created for them.

If the list is huge, make sure you schedule the next one at least +1 seconds later than Current Date/Time.

1 Like

Thank you @nocodeventure for the screenshots, but this may not work for me.

I have a CRM so my users create their own ‘team’ and each user is associated with a Company. So, I can’t know ahead of time how many team members each User will have.

To Search for ALL Users just do a search for Users.

It won’t let me. My recipient field is ‘Notification’ so that could be the issue. Should I make the User a ‘List of users’?

The trouble is, mostly I only send a Notification to a single user so I don’t think I want a ‘List of users’?

It works like this;

  • A User is part of a Team. Team members can message one another (to a single User)
  • When a new customer is saved but not contacted after 7 days I send a Notification to all team members.

The trouble is, mostly I only send a Notification to a single user so I don’t think I want a ‘List of users’?

No, I mean you need to run the workflow on a list (use schedule API workflow on a list), not that you need to have a list field on the datatype.

I’d recommend doing that itself on the backend to avoid timeouts, but even then, depending on the number of Users involved, using a recursive workflow (as @nocodeventure has outlined) might be a more stable option.

That said, if it’s just a few dozen (or even a few hundred) then running the workflow on a list should be fine (at least in my experience), and certainly simpler to set up.

So, keep the backend workflow you currently have (make sure it has a parameter for Recipient, of type User), and schedule that workflow to run 'on a list from another workflow (preferably a backend workflow), and define that list as your list or Users.

Alternately, setting up a recursive workflow will also work.

2 Likes

No, I mean you need to run the workflow on a list (use schedule API workflow on a list), not that you need to have a list field on the datatype.

Thank you. I have some (potentially dumb) questions … Sorry, I have never used backend workflows before.

I have set up the List API but I am unsure how to fill in the “List to run on” and “Job”? Also, Type of things should be Job, right?

2

I’d recommend doing that itself on the backend to avoid timeouts

I don’t understand this, sorry.

but even then, depending on the number of Users involved, using a recursive workflow (as @nocodeventure has outlined) might be a more stable option. That said, if it’s just a few dozen (or even a few hundred) then running the workflow on a list should be fine (at least in my experience), and certainly simpler to set up.

I’d imagine the very largest window company would only have a max of 20 team members so it won’t be too big.

So, keep the backend workflow you currently have (make sure it has a parameter for Recipient, of type User)

I have a query about this…

As stated, I needed a way to know if an invoice/estimate has been sent to a customer within 7 days of that customer being added to the DB. So, I created a field in the Job Datatype called invoice-or-estimate_sent which is set as default to “No”. When a new customer is added to the system, that Job is updated to invoice-or-estimate_sent = “Yes”. Everything is associated with a Job, the customer and estimate/invoice all relate back to a Job so this seemed the best way.

This is mind, shouldn’t I have a parameter for Job, of type Job?

The Type Of Thing should be ‘User’

The list to run on should be the specific list of Users you want the workflow to run on (i.e. something like This Company’s Users)

The Scheduled Date should be current/date time (or whenever you want the workflow to begin)

User should be ‘This User’

And any other parameters you need for the workflow should, of course, be whatever they need to be…

I don’t understand this, sorry.

If you’re scheduling a a workflow to run on a large list from the front end, it can time out and won’t run. So you’re better off running a backend workflow to schedule the workflow on a list.

Having said that, if you’re only talking about 20 or so Users it probably won’t be a problem to schedule it directly from the front end.

2 Likes

@adamhholmes Thank you for your further instructions, it got me a lot closer. I think I’ll have it sorted by end of tomorrow :slight_smile:

1 Like