Skip to content

Automatically Add dynamic list of Contacts to a Contact Group Using HappyFox Workflows

Views
24
Last updated

Automatically find every contact whose Contact Custom Field matches a specific value and add each of them to a Contact Group, using two connected HappyFox Workflows built around a recurring Scheduled Ticket. The solution does not stop after updating a single contact — it runs repeatedly until every matching contact has been added to the group.

 

Prerequisites

Note: HappyFox Workflows does not currently support a Contact Created or Contact Updated trigger. This solution uses a Scheduled Ticket as a recurring clock instead — the ticket is created or updated on a schedule, and each time it fires, the workflow processes one more matching contact.

Example use case

An organization has a Contact Custom Field named Is Admin. Whenever a contact's Is Admin value is Yes, that contact should be added to the Admin Contact Group. This ensures only contacts in the Admin Contact Group can access specific Support Center features.

 

Another contact custom field called Added to Group with Yes/No as values. 

How the solution works

The solution is not a single workflow — it is two workflows that hand off to each other, plus a recurring Scheduled Ticket that keeps the handoff running:

 

Each execution processes exactly one contact. Add Contact To Groups only acts on the first contact returned by Filter Contacts in that run — it does not add every returned contact at once. The workflow re-triggers itself by updating the ticket, and each re-trigger picks up the next contact in line, because the contact just added no longer matches the Filter Contacts condition. The loop continues, one contact per run, until Filter Contacts returns no results, at which point the ticket stops updating and the process ends on its own.

Note: HappyFox Workflows does not cap the number of times a ticket can re-trigger a workflow through repeated updates, so this loop is not limited by a run-count ceiling. It keeps running until every matching contact has been processed.

Workflow 1 — Ticket Created

Trigger: Ticket Created

This workflow is initiated by the Scheduled Ticket.

  1. Add a Filter Contacts action with the following condition under Match All:

    • Is Admin is Yes
    • Contact is not part of the Admin Contact Group

    This returns every matching contact as an indexed array of results (0, 1, 2, and so on), each with fields like Id and Name. For example: Contact A at index 0, Contact B at index 1, Contact C at index 2.

  2. Add an Add Contact To Groups action.

    • In Step 1, set Contact ID to the Filter Contacts merge field for index 0's Id value (the first contact in the array). This is what limits the action to one contact instead of the whole list.
    • In Step 2, set Contact Groups to the Admin Contact Group.

    After this step, Contact A becomes a member of the Admin Contact Group.

  3. Update Contact Custom Field Added to Group as Yes

  4. Add an Update Ticket action to update the Scheduled Ticket. 

    Updating the ticket triggers Workflow 2.

Workflow 2 — Ticket Updated

Trigger: Ticket Updated

This workflow repeats the same process as Workflow 1.

  1. Add the same Filter Contacts action:

    Contact A is now excluded automatically, since it was already added to the group in the previous run. The filtered result is now Contact B at index 0, Contact C at index 1.

    • Is Admin is Yes
    • Added to Group is No
  2. Check Condition If Filter Contact action has a valid result

    • Add the same Add Contact To Groups action, mapped the same way: Contact ID set to index 0's Id value, Contact Groups set to the Admin Contact Group. It adds Contact B, now the first contact in the current result, to the Admin Contact Group.

    • Update Contact custom field Added to Group as Yes for contact B using Update Contact action.

    • Add the same Update Ticket action to update the Scheduled Ticket again, which triggers Workflow 2 to run once more.

Note: The workflow continues until Filter Contacts returns no contacts. At that point, no further ticket update occurs and processing stops automatically. No manual intervention is required to end the loop.

Example run

Contact Is Admin Added to Group
Contact A Yes No
Contact B Yes No
Contact C Yes No
  1. First execution: Contact A is added to the Admin Group.
  2. Second execution: Contact B is added to the Admin Group.
  3. Third execution: Contact C is added to the Admin Group.
  4. Fourth execution: Filter Contacts returns no matching contacts. The workflow stops.

Benefits