During the switch to the new built in electronic signature documents and off of the external providers, Rock lost the ability to re-send a signature document for a registrant to a registrar for signing. There are a number of scenarios in which that creates an issue, for example if a minor signed a legal document that their parent was required to sign. In these circumstances it may be helpful to have a quick way to re-send the signature document to the correct registrar for signing. 

This recipe walks you through the steps in creating a workflow and page to allow for re-signing these documents.



Step One: Create a Signing Page

  1. Navigate to CMS Configuration > Pages and find a good parent page to place a signature page. If you have what currently is the default external site structure, a good place to put this might be the Support Pages.  
  2. Create a page and name it "Signature Document". Create a route of "signature" under the advanced settings. 
  3. In the main section of the page, add an HTML Content block that introduces the page. For example, "Signature Required - Please read the form below and enter your name only if you agree to its terms."
  4. Under that block, add a Workflow Entry block. You do not need to set the Workflow Type, but ensure that Disable Passing WorkflowId and Disable Passing WorkflowTypeId are both set to "No".
  5. When you save it will be normal to see an error message from the workflow entry block. 
  6. Set the security on this page. Because it's a legal document, we need confidence in who signed in. Change the permissions to allow viewing by "All Authenticated Users" and explicitly deny "All Un-Authenticated Users". 


Step Two: Create Workflow

Set up manually to learn... or cheat by downloading the workflow from the files below and skip ahead.

  1. Navigate to General Settings > Workflow Configuration and find a category to add your Sign Event Document workflow to. 
  2. Create a workflow and name it "Sign Event Document". For the description add "Needs provided entity to be registrant, so please launch from the registrant grid or a data view of registrants. Best setup is to launch from a custom grid action."  Set the work term to "Signature Document". 
  3. Add the following attributes. The values shown below are the keys and the text in the parenthesis is the field type. The names can match exactly, they won't be shown anywhere else.: 
    1. RegistrarPerson (Person)
    2. AppliesToPerson (Person)
    3. RegistrantId (Text)
    4. Instance (Registration Instance)
    5. Content (Text)
    6. SignatureDocumentTemplate (Signature Document Template)
    7. OldSignatureDocumentId (Text)
    8. Debug (Text)
  4. Under the first activity, add the following actions:
    1. "Set AppliesToPerson from Entity". Type of Workflow Attributes > Attribute Set from Entity. The attribute is AppliesToPerson and the template is "{{ Entity.PersonAlias.Guid }}". 
    2. "Show Error". Type of Workflow Control > Workflow Entry Show HTML. Content is "This {{ Workflow.WorkflowType.WorkTerm }} does not currently require your attention."  Set the "Run If" to "AppliesToPerson Is Blank".  
    3. "Complete Workflow". Type of Workflow Control > Workflow Complete.  Set the "Run If" to "AppliesToPerson Is Blank".  
    4. "Set Registrar Person from Entity". Type of Workflow Attributes > Attribute Set from Entity. The attribute is RegistrarPerson and the template is "{{ Entity.Registration.PersonAlias.Guid }}". 
    5. "Set Registrant Id from Entity".  Type of Workflow Attributes > Attribute Set from Entity. The attribute is RegistrantId and the template is blank.
    6. "Get Old SignatureDocumentId". Type of Utility > Lava Run. Set the attribute to OldSignatureDocumentId and enable Rock Entity. The Lava is: 
      {% assign registrantId = Workflow | Attribute:'RegistrantId' %}{% registrationregistrant id:'{{ registrantId }}' securityenabled:'false' %}{{ registrationregistrant.SignatureDocumentId }}{% endregistrationregistrant %}
    7. "Remove SignatureDocumentId from Registrant". Type of Entity > Entity Property Set. The Entity Type is Registration Registrant. The Entity Attribute is RegistrantId. Property Name is SignatureDocumentId. Property Value and Property Value Attribue should be left blank. Empty Value Handling - Set to NULL
    8. "Delete Previous Signature Documents". Type of Utility > Lava Run. Set the attribue to Debug and enable SQL. The Lava is: 
      {% comment %}
      1. First, we delete the signature document directly tied to the document ID provided.
      2. Secondly, we delete all documents for the current person that match the signature document template ID that is the current required template ID from the registration template associated with the registrant.
      {% endcomment %}
      
      {% assign documentId = Workflow | Attribute:'OldSignatureDocumentId' %}
      {% assign personId = Workflow | Attribute:'AppliesToPerson','Id' %}
      {% assign registrantId = Workflow | Attribute:'RegistrantId' %}
      
      {% if documentId !=empty %}
      {% comment %}Delete the signature document directly tied to this documentId{% endcomment %}
      {% sql statement:'command' %}
      DELETE TOP (1) FROM SignatureDocument
      WHERE Id = {{ documentId }};
      {% endsql %}
      {% endif %}
      
      {% comment %}Delete up to 20 signature documents for the current person that match the registration template's required signature document template ID for the current registrant. Limiting to 20 for safety.{% endcomment %}
      {% sql statement:'command' %}
      DELETE TOP (20) sd
      FROM SignatureDocument sd
      JOIN PersonAlias pa ON sd.AppliesToPersonAliasId = pa.Id
      JOIN RegistrationRegistrant rr ON rr.PersonAliasId = pa.Id
      JOIN RegistrationTemplate rt ON rt.Id = rr.RegistrationTemplateId
      WHERE rr.Id = {{ registrantId }}
      AND rt.RequiredSignatureDocumentTemplateId = sd.SignatureDocumentTemplateId
      AND pa.PersonId = {{ personId }};
      {% endsql %}
      {{ results }}
                      
    9. "Set Instance from Entity". Type of Workflow Attributes > Attribute Set from Entity. The attribue is "Instance" and the lava template is: 
      {{ Entity.Registration.RegistrationInstance.Guid }}
    10. "Set Signature Document Template". Type of Utility > Lava Run. The attribute is "Signature Document Template". The lava template is: 
      {% assign instanceId = Workflow | Attribute:'Instance','Object' %}
      {{ instanceId.RegistrationTemplate.RequiredSignatureDocumentTemplate.Guid }}
      
    11. "Workflow Persist". Type of Workflow Control > Workflow Persist. Set Persist Immediately to Yes.
    12. "Set Email Content". Type of Utility > Lava Run. Set the attribute to Content and the Lava to the code below. Make sure the "signature" route from the page you set up is included: 
      
      <h1>Signature Document Request</h1>
      <p>
          Please sign the document attached to finish registering {{ Workflow | Attribute:'AppliesToPerson','FullName' }} for {{ Workflow | Attribute:'Instance','Name' }}.
      </p>
      <a href="{{ 'Global' | Attribute:'PublicApplicationRoot' }}signature?WorkflowId={{ Workflow.Id }}&WorkflowTypeId={{ Workflow.WorkflowTypeId }}" target="_blank" style="border: solid 1px #3498db; border-radius: 5px; box-sizing: border-box; cursor: pointer; display: inline-block; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-decoration: none; text-transform: capitalize; background-color: #3498db; border-color: #3498db; color: #ffffff;">Sign Document</a>
      
    13. "Email Send". Type of Communications > Email Send. Set the Reply To Address to "{{ Workflow | Attribute:'Instance','ContactEmail' }}" and the Subject to "Complete Registration {{ Workflow | Attribute:'Instance','Name' }}". Set it to Save Communication History so you have a record. For the body, you can set up your template however you like, but here's a sample. Lava is used in a few places, so take note of those. Most imporantly, make sure that "{{ Workflow | Attribute:'Content' }}" ends up in your email.: 
      
      <!DOCTYPE html>
      <html>
      
      <head>
          <meta name="viewport" content="width=device-width, initial-scale=1.0" />
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>{{ Workflow | Attribute:'AppliesToPerson','FullName' }} Signature Document Request</title>
          <style>
              @media only screen and (max-width: 620px) {
                  table.body h1 {
                      font-size: 28px !important;
                      margin-bottom: 10px !important;
                  }
      
                  table.body p,
                  table.body ul,
                  table.body ol,
                  table.body td,
                  table.body span,
                  table.body a {
                      font-size: 16px !important;
                  }
      
                  table.body .wrapper,
                  table.body .article {
                      padding: 10px !important;
                  }
      
                  table.body .content {
                      padding: 0 !important;
                  }
      
                  table.body .container {
                      padding: 0 !important;
                      width: 100% !important;
                  }
      
                  table.body .main {
                      border-left-width: 0 !important;
                      border-radius: 0 !important;
                      border-right-width: 0 !important;
                  }
      
                  table.body .btn table {
                      width: 100% !important;
                  }
      
                  table.body .btn a {
                      width: 100% !important;
                  }
      
                  table.body .img-responsive {
                      height: auto !important;
                      max-width: 100% !important;
                      width: auto !important;
                  }
              }
      
              @media all {
                  .ExternalClass {
                      width: 100%;
                  }
      
                  .ExternalClass,
                  .ExternalClass p,
                  .ExternalClass span,
                  .ExternalClass font,
                  .ExternalClass td,
                  .ExternalClass div {
                      line-height: 100%;
                  }
      
                  .apple-link a {
                      color: inherit !important;
                      font-family: inherit !important;
                      font-size: inherit !important;
                      font-weight: inherit !important;
                      line-height: inherit !important;
                      text-decoration: none !important;
                  }
      
                  #MessageViewBody a {
                      color: inherit;
                      text-decoration: none;
                      font-size: inherit;
                      font-family: inherit;
                      font-weight: inherit;
                      line-height: inherit;
                  }
      
                  .btn-primary table td:hover {
                      background-color: #34495e !important;
                  }
      
                  .btn-primary a:hover {
                      background-color: #34495e !important;
                      border-color: #34495e !important;
                  }
              }
      
          </style>
      </head>
      
      <body style="
              background-color: #f6f6f6;
              font-family: sans-serif;
              -webkit-font-smoothing: antialiased;
              font-size: 14px;
              line-height: 1.4;
              margin: 0;
              padding: 0;
              -ms-text-size-adjust: 100%;
              -webkit-text-size-adjust: 100%;
          ">
          <span class="preheader" style="
              color: transparent;
              display: none;
              height: 0;
              max-height: 0;
              max-width: 0;
              opacity: 0;
              overflow: hidden;
              mso-hide: all;
              visibility: hidden;
              width: 0;
              ">{{ Workflow | Attribute:'AppliesToPerson','FullName' }} Signature Document Request</span>
          <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body" style="
              border-collapse: separate;
              mso-table-lspace: 0pt;
              mso-table-rspace: 0pt;
              background-color: #f6f6f6;
              width: 100%;
              " width="100%" bgcolor="#f6f6f6">
              <tr>
                  <td style="font-family: sans-serif; font-size: 14px; vertical-align: top" valign="top">
                      &nbsp;
                  </td>
                  <td class="container" style="
                  font-family: sans-serif;
                  font-size: 14px;
                  vertical-align: top;
                  display: block;
                  max-width: 580px;
                  padding: 10px;
                  width: 580px;
                  margin: 0 auto;
                  " width="580" valign="top">
                      <div class="content" style="
                      box-sizing: border-box;
                      display: block;
                      margin: 0 auto;
                      max-width: 580px;
                      padding: 10px;
                  ">
                          <!-- START CENTERED WHITE CONTAINER -->
                          <table role="presentation" class="main" style="
                      border-collapse: separate;
                      mso-table-lspace: 0pt;
                      mso-table-rspace: 0pt;
                      background: #ffffff;
                      border-radius: 3px;
                      width: 100%;
                      " width="100%">
                              <!-- START MAIN CONTENT AREA -->
                              <tr>
                                  <td class="wrapper" style="
                          font-family: sans-serif;
                          font-size: 14px;
                          vertical-align: top;
                          box-sizing: border-box;
                          padding: 20px;
                          " valign="top">
                                      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="
                              border-collapse: separate;
                              mso-table-lspace: 0pt;
                              mso-table-rspace: 0pt;
                              width: 100%;
                          " width="100%">
                                          <tr>
                                              <td style="
                                  font-family: sans-serif;
                                  font-size: 14px;
                                  vertical-align: top;
                              " valign="top">
                                                  {{ Workflow | Attribute:'Content' }}
                                              </td>
                                          </tr>
                                      </table>
                                  </td>
                              </tr>
      
                              <!-- END MAIN CONTENT AREA -->
                          </table>
                          <!-- END CENTERED WHITE CONTAINER -->
      
                          <!-- START FOOTER -->
                          {{ 'Global' | Attribute:'EmailFooter' }}
                          <!-- END FOOTER -->
                      </div>
                  </td>
              </tr>
          </table>
      </body>
      
      </html>
      
    14. "Electronic Signature". Type of Workflow Control > Electronic Signature. Set the Signature Document Template Attribute to "Signature Document Template". Set Applies to Person to "AppliesToPerson" and Assigned To Person to "Registrar Person". Set the Document Name to "{{ Workflow | Attribute:'AppliesToPerson','FullName' }} ({{ Workflow | Attribute:'Instance','Name' }})".
    15. "Show HTML". Type of Workflow Control > Workflow Entry Show HTML. Set Hide Status Message to Yes. Set the HTML to the code below. Make sure to turn on a receipt email on the template if you say this: 
      
      <p>Thank you for signing. You have been emailed a copy of the document for your records.</p>
      
    16. "Complete Workflow". Type of Workflow Control > Workflow Complete


Step Three: Add a Workflow Launch Page

  1. Navigate to CMS Configuration > Pages
  2. In the pages tree, click on the Event Registration page and add a child named "Re-Send Signature Document" with the route "workflow-signature"
  3. Add a Workflow Launch block to the page and set the Workflow to the one you created.
  4. Set the Panel Title to "Re-Send Signature Documents".


Step Four: Add Grid Custom Action

  1. Navigate to the registration instance registrants page for any registration such as /web/event-registrations/1297/registrants - you should see the registrants grid.
  2. Edit the "Registration Instance - Registrant List" block and open the Custom Grid Options tab.
  3. Enable the Workflow Launcher and add a custom action named Re-Send Signature Document with the route /page/workflow-signature?WorkflowTypeId=SET-TO-YOUR-WORKFLOW-TYPE-ID
  4. In the last step, make sure to get the workflow type Id from the workflow you created.
  5. Set the Icon CSS class to "fa fa-file-signature"


Step Five: Testing

  1. Register yourself or a test person for an event that has a signature document.
  2. Navigate to the registration instance page for that registration.
  3. Select the registrant you'd like to resend a signature document for.
  4. In your registrants grid you should now have a new icon on the top right for re-sending the signature document.
  5. Click the icon and then click Launch to start a workflow for the registrant. You can select as many registrants as you need.
  6. The workflow may take a minute to process. Once it does, the signature document icon on the registrant will show a red icon and the document will no longer be on the person documents page. The registrar will also get an email requesting a new signature.