---
schema_version: "1"
id: a7ea1f6ed6b58c962331d68a6bfd0dd70ea0b427cbf2220297d971c88340936d
title: Convert Automations to Asynchronous for Invoice Batch Runs
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/billing_invoice_run_sync_process.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.billing_invoice_run_sync_process.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: f8aea4f68ee3bd3dc17b74d3ee9a925a158c0b5c5ed39efcae0940615554d11a
description: Identify active flows and Apex triggers on Billing objects and convert them to asynchronous processes before you schedule an invoice batch run. Synchronous automations can stop a run or leave invoices in Draft In Progress, Posting In Progress, or Error.
products:
  - Revenue Cloud
release: "264"
---
# Convert Automations to Asynchronous for Invoice Batch Runs

Identify active flows and Apex triggers on Billing objects and convert them to asynchronous processes before you schedule an invoice batch run. Synchronous automations can stop a run or leave invoices in Draft In Progress, Posting In Progress, or Error.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions with <a href="https://help.salesforce.com/s/articleView?id=ind.revenue_licenses_areas_and_features.htm&amp;release=264.0.0&amp;type=5">the Revenue Cloud Advanced license or the Revenue Cloud Billing license</a></td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d80422e72">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">To review and convert record-triggered flows:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">Manage Flow</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">To view Apex triggers:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">View Setup and Configuration</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">To convert Apex triggers:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">Author Apex</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">To recover stuck invoices:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80422e72 ">
              <p>Billing Admin permission set</p>
              <p>OR</p>
              <p style="margin-bottom:0;">Billing Operations User permission set</p>
            </td>

          </tr>
        </tbody>
      </table>

A record-triggered flow or Apex trigger is tied to an object, such as Invoice or Invoice Line. You define and activate the flow on that object in Flow Builder. A person who has the Author Apex permission defines the Apex trigger on that object and sets it to active. These automations are custom. Billing doesn't create them. See [Activate or Deactivate a Flow](https://help.salesforce.com/s/articleView?id=platform.flow_distribute_activate.htm&language=en_US) and [Define Apex Triggers](https://help.salesforce.com/s/articleView?id=platform.code_define_trigger.htm&language=en_US).

When an invoice batch run generates invoices, the run creates or updates records on Billing objects. Those objects include invoices, invoice lines, tax lines, debit and credit memos, billing schedules, and billing period items. Any active flow or trigger on a Billing object then runs for every record the invoice batch run saves.

A synchronous automation runs as part of saving the record. The invoice batch run doesn't finish saving the invoice until that flow or trigger is done. If the automation queries related records for every invoice, the run can hit processing limits or time out. Invoices can remain in Draft In Progress, Posting In Progress, or Error.

An asynchronous automation waits until the invoice records are saved, then runs. The batch run can finish generating invoices. The flow or trigger still runs, just not while the invoice is being saved.

1. From Setup, in the Quick Find box, enter Flows, and then select **Flows**.
2. Review active record-triggered flows on these Billing objects.
    - Invoice
    - Invoice Line
    - Invoice Line Tax
    - Debit Memo
    - Debit Memo Line
    - Debit Memo Line Tax
    - Credit Memo
    - Credit Memo Line
    - Credit Memo Line Tax
    - Billing Schedule
    - Billing Period Item
3. From Setup, in the Quick Find box, enter Apex Triggers, and then select **Apex Triggers**.
4. Review active triggers on the same objects.
5. To list the automations with SOQL, open the Developer Console Query Editor.
    
    Sample scripts:
    
    For the flow query, select **Use Tooling API**. For the Apex trigger query, leave **Use Tooling API** cleared.
    
    Flows:
    
    ```
    SELECT Id, IsActive, Label, ProcessType, ManageableState, TriggerObjectOrEventId, TriggerObjectOrEventLabel, TriggerType FROM FlowDefinitionView WHERE TriggerObjectOrEventId IN ('Invoice','InvoiceLine','DebitMemo','DebitMemoLine','CreditMemo','CreditMemoLine','InvoiceLineTax','DebitMemoLineTax','CreditMemoLineTax','BillingSchedule','BillingPeriodItem') AND IsActive = TRUE
    ```
    
    Apex triggers:
    
    ```
    SELECT Id, TableEnumOrId, Name, Status FROM ApexTrigger WHERE TableEnumOrId IN ('Invoice','InvoiceLine','DebitMemo','DebitMemoLine','CreditMemo','CreditMemoLine','InvoiceLineTax','DebitMemoLineTax','CreditMemoLineTax','BillingSchedule','BillingPeriodItem') AND Status = 'Active'
    ```
6. For each after-save record-triggered flow, move the logic to a Run Asynchronously path so it runs after the invoice save commits. See [Triggered Flows](https://help.salesforce.com/s/articleView?id=platform.flow_concepts_trigger.htm&language=en_US).
7. For each Apex trigger, work with a person who has the Author Apex permission to move the logic out of the record save. Use queueable Apex or an Apex trigger on a change event, which runs after the save is complete. See [Queueable Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm) and [Subscribe with Apex Triggers](https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_subscribe_apex_triggers.htm).

After you convert the automations, schedule the next invoice batch run. See [Generate Invoices Automatically Based on Billing Schedules](https://help.salesforce.com/s/articleView?id=ind.billing_automate_invoice_run_schedules.htm&release=264.0.0&type=5 "Set up invoice schedulers to generate invoices on a schedule or on demand. Select billing schedules by target date, billing period count, or both. Generate invoice documents during the run, or use a catch-up bill run to advance migrated schedules without creating invoices.").

If invoices from an earlier run are stuck in Draft In Progress, Posting In Progress, or Error, click **Recover** on the invoice batch run. Then generate invoices again.