I have recently started creating step programs for our church and thought I would share some knowledge. Steps are a fantastic way to see things quickly and track a person's progress. In my example I will show you how you can add all of your members who have a Baptism date in their extended attributes to a baptism step, marked as completed, with the date from the attribute.

I want to point out a few things before we get to deep. While you can automate step completion with a data view, the first time the automation runs it will populate the date completed date as the current date. If this isn’t something you are concerned with then you can just create your data view and add it to the step, no need to read any further than the next paragraph(tip!), however if you want to keep the correct date on the step or even add step attribute data then get ready to dig in.

Caveat: If you are not on v12 yet you might want to hold off on the automation part of this, there was a bug that was fixed in v12(https://github.com/SparkDevNetwork/Rock/issues/4390). If you continue with the automation, you will likely end up with many duplicate records.


If you are not familiar with loops in workflows then I highly recommend watching Mark Wamplers “Workflow Looping” in the RX 2020 sessions, loops in workflows can be dangerous and he does a fantastic job covering this. Also of note is Daniel Hazelbakers Workflow Stimpack plugin which takes all the work out of looping... Seriously that 1 action justifies the cost.


Okay, now that we’ve got that out of the way let’s get to it. While I’m using the Baptism date in this example you can use this method for any person attribute, or any attribute for that matter. We are going to accomplish this using a workflow,2data views, and a step in a step program. I will include my workflow to download but it must be edited for your church.


While I am going to use 2 data views in this example ,it is not always necessary. I have found that if you have more than a couple hundred people you want to add, you will want to use the 2 data view solution as the workflow will timeout after about 250-275 records. For this reason, I will be limiting my workflow to only run through 250 people at a time, which means I will need to run the workflow more than once. Since I need to run the workflow more than once it also creates an issue with the workflow step add action if you don’t take precautions.

Let me clarify, I am using the out of the box Baptism Step that comes with rock, in the settings for it, it does NOT allow multiple steps, if you try to run this workflow action on a step configured this way and it contains a person who already has the step, the workflow will fail and error out. The easiest way to stop this is by using 2data views. Of course, if you have less than 250 people that you want to add you can just make 1data view and run the workflow once and be done.

StepConfiguration.png


Now Lets create some data views. First create a person data view looking for people who have a Baptism step and name it “Person Has Baptism Step”. If you do not have anyone in the step, then it should not return anyone.

HasStep.png


Next create a person data view that looks for anyone who has a baptism date that is not blank and NOT In the “Person Has Baptism Step” data view, make sure you have Show if All of these are True set and name it “Person Has Baptism Date”.

HasBaptismDate.png

This will be the data view that we use in the workflow so take note of the Id of this data view. Each time you run the workflow, people who already have the step are not included so this stops the error in the workflow from happening.


I have included a workflow with everything already setup ,but you need to edit a few things first.


  • Set the “Step Program Step Type” and “Step Program Step Status” attributes to the Step you have in your rock instance.
  • Set the correct data view id in the“(create) List of People” action in the Start activity.
  • Set the correct attribute key in the “(set) Date Attribute” in the Loop action

Workflow.png

After you edit and save all that is left is to run the workflow. I would encourage you to try this out on the demo site or on a test system to make sure you understand it. If you can’t do that then run it on a test step with a small amount of people.
CompletedSteps.png

The lava below gets all the people in a data view and limits it to 250
{% person dataview:'15' limit:250 %}  
    {% for person in personItems %} 
        {{ person.PrimaryAlias.Guid }}{% unless forloop.last %},{% endunless %} 
    {% endfor %}
{% endperson %}

The Lava below gets a persons baptism date

{% assign date = Activity | Attribute:'Person','Object' | Attribute:'BaptismDate' %}

I left some of my lava in the workflow lava actions commented out so you could get an idea of other ways you can do this. I’ve used this to add people from a group to a step with the date added as the step completion date. Of course you can change this to anything you want. You can also add step attributes via this workflow in the same way that we did the dates.


And finally yes you could use SQL to do the same thing that we did with the workflow and it runs much faster and in less steps I’m just not that good with SQL yet.

Hope this helps!