---
title: "Add an approval counter to fast-track an approval"
canonical: "https://support.appfire.com/space/CDML/650315109/Add%20an%20approval%20counter%20to%20fast-track%20an%20approval"
format: markdown
---
> Macro (aura-html)


> Macro (excerpt)
> 
> For a content review with multiple assigned reviewers, increment a metadata value each time a reviewer approves the content and set a trigger to approve the page when a set number of reviewers have approved the page

## Overview

<span style="color: #172b4d">Content reviews often assign several reviewers. Once assigned, the workflow requires that all the assigned reviewers agree - either </span><span style="color: #1d1c1d">**Approve**</span><span style="color: #172b4d"> or </span><span style="color: #1d1c1d">**Reject**</span><span style="color: #172b4d"> - before transitioning to another state.</span>

![image](media://ad89800b-8745-4a5f-99be-b54ca0b25c89)


<span style="color: #172b4d">Rather than waiting for all the assigned reviewers to approve the content, the workflow author may want to transition the workflow after receiving approvals from a set number of them.</span>

<span style="color: #172b4d">We can do this using a metadata item as a counter and incrementing the counter using the </span><span style="color: #172b4d">[increment-metadata](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650250264)</span><span style="color: #172b4d"> macro.</span>

## <span style="color: #172b4d">Set and increment the approval counter to action the approval</span>

<span style="color: #172b4d">The workflow uses the following trigger actions:</span>

- <span style="color: #172b4d">initialize a counter value using </span><span style="color: #172b4d">[set-metadata](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650251172)</span><span style="color: #172b4d"> macro</span>
- <span style="color: #172b4d">increment the counter value using the </span><span style="color: #172b4d">[increment-metadata](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650250264)</span><span style="color: #172b4d">** **</span><span style="color: #172b4d">macro</span>
- <span style="color: #172b4d">action the </span>`approved`<span style="color: #172b4d"> transition using the </span><span style="color: #172b4d">[approve-page](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649826933)</span><span style="color: #172b4d"> macro when the counter value reaches a specified number</span>

In the simple increment metadata example, the content is approved when three of the five assigned reviewers have approved the content.

```plaintext
{workflow:name=Increment Metadata Counter for an approval}
    {description}
        A simple approval workflow with use of increment-metadata macro to set the number 
        of assigned reviewer approval decisions to trigger the approval transition.
    {description}
    {state:Review|approved=Approved|Rejected=Rejected|taskable=true}
        {approval:Review|user=&suni,adam,elle,matilde,milo}
    {state}
	{state:Rejected|submit=Review|taskable=true}
	{state}
    {state:Approved|final=true|updated=Review|hideselection=true}
    {state}
	{trigger:statechanged|state=Review}
    	{set-metadata:approval-counter}0{set-metadata}
	{trigger}
	{trigger:pageapproved|approval=Review|partial=true}
    	{increment-metadata:approval-counter}
	{trigger}
	{trigger:pageapproved|approval=Review|@metadatafield.approval-counter@=3}
    	{approve-page:Review|comment=Three reviewers have approved the content}
	{trigger}
{workflow}
```

This example can be useful when you have a large number of users who are members of a global Confluence group, which is the assigned reviewer group, and your approval practice does not require all assigned users to undertake the content review.

Here's how each trigger action works

| **Trigger** | **Event** | **Action macro** | **Notes** |
| --- | --- | --- | --- |
| Initialize the metadata | `statechanged` | <span style="color: #172b4d">[set-metadata](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650251172)</span> | - sets the metadata as `approval-counter`
- initializes (or resets) the metadata `approval-counter` value to zero on the state change event to the **Review** state |
| Approval counter | `pageapproved` | [increment-metadata](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650250264) | - increments the `approval-counter` value by 1 each time a reviewer approves the content
- condition `partial=true`  means that the trigger listens for each individual approval decision |
| Approve the page | `pageparameterupdate` | <span style="color: #172b4d">[approve-page](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649826933)</span> | - approves the content when the parameter value is updated of the `approval-counter` is incremented to a value of 3 (trigger event condition is `@metadatafiled.approval-counter@=3)` |


An individual reviewer's rejection decision does not impact the metadata approval-counter value, but it does impact the context of an approval transition.

For example

- the <span style="color: #172b4d">[approve-page](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649826933)</span> macro is triggered when the `approval-counter` value is 3, even if one or more of the assigned reviewers have rejected the content
- the `approval-counter` value is not decreased if a previous user changes their **approved** decision to **rejected**

This may mean the `approve-page` action can occur if

- an assigned approver has rejected the content, but three other assignees have approved the content
- a single assignee approves and rejects the content two times and then undertakes a third approval decision without any other assignee approving the content

By managing a rejection decision, we obviously need to avoid these mixed decisions causing an overall approval.

## Manage reviewer rejection of the content

An additional trigger may be useful to initiate a [fast-tracked rejection](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650217904).

```plaintext
{trigger:pagerejected|approval=Review|partial=true}
      {set-state:Rejected}
{trigger}
```

A single rejection decision will transition the content to the **Rejected** state.

The addition of the fast-tracked rejection trigger to this workflow can be used to manage: 

- when a single reviewer rejects the content
- when a reviewer changes their content review decision before any transition occurs