Update Jira after Ironclad Workflow Completed

# Goal

Update a Jira issue after an Ironclad workflow is completed.

# Overview

This solution pattern provides a method for updating a Jira issue after an Ironclad workflow is completed. In this example, a team working in Jira would like to have a link to the final record in Ironclad’s repository. When a workflow is completed in Ironclad, it will trigger the Zap in this guide and update Jira.

**Prerequisite**: The [Launch Ironclad Workflow from Jira](https://developer.ironcladapp.com/docs/launch-ironclad-workflow-from-jira) solution pattern must be completed beforehand. That solution pattern stored key Jira information (`Jira Issue ID`) in the Ironclad workflow and key Ironclad workflow data (`Ironclad Workflow ID`) in the Jira issue.

# Details

The figure below shows the steps that will be part of the Zapier rule that we will configure for this solution. We'll now walk through the steps to configure this rule and make the necessary configuration changes in Jira and Ironclad.

<figure>
  <img src="https://files.readme.io/9727838-4._Ironclad_Completion_-_Zapier_Rule_Overview.png" alt="Zapier rule overview.">
  <figcaption>
    <p>Zapier rule overview.</p>
  </figcaption>
</figure>

1. **In Zapier**, create a new Zap. Add an **Ironclad** trigger and select **New Workflow Event** as the event. Click **Continue** and select your Ironclad account.

   1. Select **Workflow Completed** as the workflow event.

      The trigger uses Ironclad's [workflow\_completed](https://developer.ironcladapp.com/docs/webhook-event-types#workflow_completed) webhook in the background to detect completed workflows.

   <figure>
     <img src="https://files.readme.io/15503bd-4._Ironclad_Completion_-_Step_1a.png" alt="Ironclad workflow complete event trigger.">
   </figure>

   2. Complete a workflow in Ironclad and test the trigger by selecting an event with workflow\_completed in its response.

   <figure>
     <img src="https://files.readme.io/c55f97a-4._Ironclad_Completion_-_Step_1b.png" alt="Ironclad workflow complete event trigger test.">
   </figure>

2. **In Zapier**, add a **Filter** action to verify that the workflow’s template ID matches the relevant workflow design.
   <figure>
     <img src="https://files.readme.io/4cdc1be-4._Ironclad_Completion_-_Step_3.png" alt="Filter webhook event for template ID.">
   </figure>

3. **In Zapier**, add a **Formatter** action to extract the record ID from the webhook payload.

   1. Select the **Utilites** action event.
   2. Select the **Pick from list** transform and **Choose first** operation.
   3. Select the `Workflow Record IDs` value from the trigger.

   <figure>
     <img src="https://files.readme.io/816d3f9-4._Ironclad_Completion_-_Step_4a.png" alt="Extract record ID from workflow completed event.">
   </figure>

   4. Test the formatter and verify that a single value is extracted.

   <figure>
     <img src="https://files.readme.io/a09074c-4._Ironclad_Completion_-_Step_4b.png" alt="Successful formatter test result.">
   </figure>

4. **In Zapier**, add an **Ironclad** action and select **Find a Record** as the event. The action will send a request to the [Retrieve a Record](ref:retrieve-a-record) endpoint to retrieve the record's metadata. The record holds the final set of metadata inclusive of changes during the archive step. For **Record ID** select the record ID field extracted by the Formatter step above.

<figure>
  <img src="https://files.readme.io/5f17a3d-4._Ironclad_Completion_-_Step_5.png" alt="Retrieve Ironclad record metadata.">
</figure>

5. **In Zapier**, add a **Find Issue in Jira** action. Configure it to search for a Jira issue using the Jira issue ID retrieved from the record in step 5.

<figure>
  <img src="https://files.readme.io/7f46fe5-4._Ironclad_Completion_-_Step_6.png" alt="Find issue in Jira.">
</figure>

6. **In Zapier**, add an **Update Issue in Jira** action.
   1. Follow the steps in [Configure Jira Issue Update](https://developer.ironcladapp.com/docs/launch-ironclad-workflow-from-jira#zapier---configure-jira-issue-update) to update the Jira issue data.
   2. Map the Jira field, `Ironclad Record ID`, to the record ID field from step 3.
   3. Map the Jira field, `Ironclad Record URL`, to `https://[YOUR_IRONCLAD_DOMAIN]/record/[RECORD_ID]`.
   4. Map any additional fields you wish to transfer from the Ironclad record to Jira.

<figure>
  <img src="https://files.readme.io/39204ff-4._Ironclad_Completion_-_Step_7.png" alt="Update Jira issue with record data.">
</figure>

7. **Publish your rule**. Congratulations, you have a Zap that can update a Jira issue when an Ironclad workflow has been completed!