Now that everyone is working from home, it may be hard to feel connected. 

We built a simple-to-use tool that allows our staff to leave each other little nuggets of encouragement on Rock. 

Here's how it works.

We have a page with all of our staff's photos and names (I have hidden names in the screenshot):

Screen Shot 2020-03-31 at 4.43.54 PM.png

Every time you load this page it randomizes the order so different people show up at the top.

When you click on a person it loads this form: 

Screen Shot 2020-03-31 at 4.47.30 PM.png

You type something up and then hit submit! 

Then the next time that person hits the Rock Home page they will see this pop up:

Screen Shot 2020-03-31 at 4.42.34 PM.png

If they hit complete it will remove that encouragement so that it won't pop up next time they visit the home page, if they hit close it will just close the pop over which will appear again next time they log in. 


So here's how to build it all. 

The staff page: 

1) It's a Dynamic Data Block. 

This SQL is how we get our Staff, it's testing for an HR attribute that we have. So basically this Sql is saying if their Job title attribute is not blank show them on this page. If you have an HR attribute or staff attribute you could replace the "21811" with that attribute Id to create your list of staff. 

Query:

SELECT *
 FROM [Person] p
   
    INNER JOIN AttributeValue AV ON AV.EntityId = p.[Id] AND AV.AttributeId = 21811

 WHERE AV.Value!=''
ORDER BY NEWID()

Formatted Output: (Change the URL to have your church's URL in the link and the workflow Id to the workflow you upload in step 2.)

<style>
img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
</style>
<div class="panel panel-block">
 <div class="panel-heading">
   <h4 class="panel-title"><i class="fas fa-laugh-beam"></i>Encourage Staff</h4>
 </div>
 <div class="panel-body">
   <ul class="list-unstyled">
 {% for row in rows %}
<div class='col-md-3'>
<div class='well' style='text-align: center;'>
{%assign personstaff = row.Id | PersonById%}
 <li>
      <a href="https://YOURURL.com/WorkflowEntry/315?Personal={{personstaff.PrimaryAlias.Guid}}" target="_blank"><img src="{{ personstaff.PhotoUrl }}" width="200" height="200"/><br>{{row.NickName}} {{row.LastName}}</a>
      
      </li>
    </div>  
    </div>
 {% endfor %}
   </ul>
 </div>
 </div>


2) Upload the attached Workflow called 'Encourage Staff'.(Change the Workflow Id in the Formatted Output from 315 ^^ to match the imported Id).

3) Upload the "Complete Encourage Staff Workflow".


Now add the pop up to your home page!

1) Put an HTML block on the page (enable SQl lava command on the block).

2) Add this:

{% sql %}
Declare @Today datetime = CONVERT(date, getdate())
DECLARE @PersonAliasGuid int = '{{CurrentPerson.Id}}'
Select w.Id, pa.PersonId, p1.Value,p.FirstName,p.LastName, p2.FirstName as EncouragerFN, p2.LastName as EncouragerLN
From Workflow w
Join AttributeValue person on person.EntityId = w.Id and person.AttributeId = 30917
Join PersonAlias pa on try_cast(person.Value as uniqueidentifier) = pa.[Guid]
Join Person p on p.Id= pa.PersonId
Left Join AttributeValue p1 on p1.EntityId = w.Id and p1.AttributeId = 31065
Join PersonAlias pa2 on pa2.Id = w.InitiatorPersonAliasId
Join Person p2 on p2.Id = pa2.PersonId
Where w.[Status] = 'Encourage' and w.[WorkflowTypeId]='315' and pa.PersonId = @PersonAliasGuid



{% endsql %}
{% assign count = results | Size %}
{% if count > 0 %}
<div class="modal fade" id="myModal" role="dialog" tabindex="-1" style="display: none; margin-top: -164.75px;" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
            <div class='modal-header'>
             <button type="button" class="close pull-right" style="margin:5px" data-dismiss="modal"><i class="fal fa-times"></i> Close</button>
            <center><h2 style="text-align: center;">
           {% assign hour = 'Now' | Date:'HH' %}
{% if hour <= 11 %}
   Good Morning {{ CurrentPerson.NickName }}!
{% elseif 11 < hour <= 18 %}
 Good Afternoon {{ CurrentPerson.NickName }}! 
{% elseif hour >18 %}    
  Good Evening {{ CurrentPerson.NickName }}!
{% endif %}</h2></center>
            </div>
                <div class="modal-body">
                <!-- <button type="button" style="position:fixed; margin:5px" class="close no" data-dismiss="modal"> <i class="fal fa-comment-alt-times"></i> Hide Alert</button> -->
                   
                    
                    <div class="row">
                        <div class="student-event-card" style="margin: 0px;min-height:auto;padding:0px 20px 20px 20px;border: 0px;min-width:100%">
                         {% for item in results %}
                         <a href='https://YOURURL.com/page/1449?wid={{item.Id}}'><button type="button" class="close pull-right"><i class="fal fa-check"></i> Complete</button></a><br>
                         
                         <p><i class="fas fa-laugh-beam"></I>
                    {{ item.Value}} </p>
                    <p>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-heart"></i> {{item.EncouragerFN}} {{item.EncouragerLN}}</p> 
                    <hr>
    {% endfor %}
                              
                           
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    
<script>
localStorage.removeItem("hideAlert2");
if (!localStorage.hideAlert20) {
  
   $(window).on('load',function(){
        $('#myModal').modal('show');
    });
    
    }
    else {
}
$(".no").on("click", function() {
  localStorage.setItem('hideAlert2', true);
});
</script>
{%endif%}

You will need to replace the attribute Id's in the above Sql for this to work.

Replace 30917 with the Id of the workflow attribute that shows the person receiving encouragement.

Replace 31065 with the Id of the workflow attribute that has the encouragement note.

Replace the Workflow Type Id of 315 with the imported "Encourage Staff"workflow id.
Both workflows are in the attached file.

You will need to change the URL for the complete button. To do that:

  1. Create a new page.
  2. Create two blocks. An HTML block and a Redirect Block.
  3. In the redirect block put the URL as your Rock homepage
  4. In the HTML block turn on the activate workflow lava action and put the following:
  5. {%assign Pop = PageParameter:'wid'%}
    {% workflowactivate workflowtype:'316' wid:'{{Pop}}' %}
    
    {% endworkflowactivate %}

    Make sure to change in the Modal pop-up lava you change the URL to match the page Id of this page.

    You're all set!