Skip to content

Workflow Launcher

Chuck Bump edited this page Mar 4, 2019 · 5 revisions

The workflow launcher is a block and a job that are useful for starting workflows with sets of entities. It was developed to provide a set of tools to make administration of Rock just a little easier. Please note that it is very easy to launch a LOT of workflows very quickly so be careful!

Workflow Launcher Block

The block allows the user to select a workflow, then select from various entity types such as a group or dataview and then launch a workflow with the groupmember or person as the entity. The two major use cases for this block has been situations where we created a registration or a group without a workflow trigger and then decided later to add that trigger. We were then easily able to trigger all the workflows without having to do anything fancy.

Scheduled Job

The workflow launcher job allows for launching workflows from every row within a SQL result set or from every entity within a selected DataView.

DataView

If a DataView is selected, a new workflow will be launched for every entity within that DataView result at the time the job is run. Please keep in mind that the entity type will be determined by the DataView so ensure that the workflow is setup to map the entity to the proper field type in the workflow attributes.

SQL

The workflow launcher job is very similar to the existing launch workflow job except it allows you to launch a whole bunch of workflows based on the outputs of a SQL statement. The columns from the SQL will be mapped automatically to attributes in the respective workflow instance launched for each row.

For example if you wanted to perform a workflow with everyone who has attended a certain set of groups in the last 7 days you might use the following SQL:

SELECT 
pa.[Guid] AS Attendee
g.[Guid] as [Group]
    FROM Attendance a
    JOIN [Group] g ON g.Id = a.GroupId
    JOIN [PersonAlias] pa ON pa.Id = a.PersonAliasId
    WHERE g.GroupTypeId = 25
    AND a.StartDateTime >= DATEADD(day,-7, GETDATE())

Your workflow would need a Person attribute with the key "Attendee" and a Group attribute with the name "Group". When the job runs a new workflow for every person will be created with the appropriate values populated in the attribute values.