# Commerce in Automation

Start automation flows from quote and order events, and let flows read, create, publish, accept, convert and confirm Commerce records.

Source: https://support.rework.com/article/commerce-in-automation

> **In plain words:** An **automation flow** is a set of steps that run by themselves when something happens, built in Rework's Automation app. Commerce gives flows **triggers** (events that start a flow, such as "Quote accepted") and **actions** (steps that do something in Commerce, such as "Create order"). Use them to remove repeated clicks, for example to turn every accepted quote into an order. New to Commerce words? See [Commerce basics](https://support.rework.com/article/commerce-basics).

**Where to find it:** in the Automation app's flow builder, under the **Quotes** and **Orders** groups. **Who can use it:** anyone who builds flows. Each step runs with the rights of the person who runs the flow, so it can only do what that person could do in Commerce.

## Before you start

- A quote service or order service in Commerce for the flow to watch or write to. See [Services](https://support.rework.com/article/commerce-services).
  
- The person who runs the flow has the right to do each step in Commerce, for example to publish quotes in that service.
  

## Triggers: what can start a flow

Pick **Quote event** ("Starts when something happens to a quote") or **Order event** ("Starts when something happens to an order"). Then choose:

- **Trigger on**: the event.
  
- **Quote service** or **Order service**: only records in this service start the flow.
  

| 
Quote events

 | 

Order events

 |
| --- | --- |
| 

**Quote created**

 | 

**Order created**

 |
| 

**Quote published**

 | 

**Order confirmed**

 |
| 

**Quote approval requested**

 | 

**Order approval requested**

 |
| 

**Quote approved** (every approver approved)

 | 

**Order approved**

 |
| 

**Quote approval rejected**

 | 

**Order approval rejected**

 |
| 

**Quote signed**

 | 

**Order fulfilled** (every line delivered)

 |
| 

**Quote accepted**

 | 

**Order paid**

 |
| 

**Quote paid**

 | 

**Order completed**

 |
| 

**Quote cancelled**

 | 

**Order closed**

 |
| 

**Quote declined** (the customer declined, or it was marked declined)

 | 

**Order cancelled**

 |

An event fires whoever caused it: a person in Commerce, the customer on their page, the customer portal, an inbound email or a renewal. The record's details (name, code, total, customer, status and the service's custom fields) are available to the next steps.

> **Note:** **Test step** on a trigger uses a made-up sample ("Sample quote", "Sample order"), not a real record. A later step tested on it finds nothing, which is expected.

## Actions: what a flow can do

| 
Action

 | 

What it does

 |
| --- | --- |
| 

**Get quote** / **Get order**

 | 

Reads a record's details. If the record is not found, **Found** is false instead of an error.

 |
| 

**Create quote** / **Create order**

 | 

Creates a draft in a service, with catalog lines and prices from the pricebook.

 |
| 

**Publish quote**

 | 

Makes a draft quote live and gives it a code, with the same checks as the **Publish** button.

 |
| 

**Mark quote accepted**

 | 

Records that the customer accepted. This cannot be undone.

 |
| 

**Convert quote to order**

 | 

Books an accepted quote as an order in the order service you choose.

 |
| 

**Confirm order**

 | 

Confirms a draft order and gives it a code.

 |

**Create quote** and **Create order** fields:

- **Quote service** or **Order service**, **Quote name** or **Order name** (required).
  
- **Customer account** and **Contact** (the contact must belong to the account).
  
- **Line items**: price entries with quantities. Prices always come from the pricebook. Up to 100 lines, one currency.
  
- **Quote fields** or **Order fields**: the service's simple custom fields.
  
- Quotes only: **Valid until** and **Cover note**.
  
- **Only once per**: a value such as the trigger's record ID. If the flow runs again with the same value, it does not create a second record and returns the first one.
  

The person running the flow becomes the owner of records it creates.

**Confirm order** has a switch, **Confirm customer requests**. When off, orders that came from the customer portal, an email or AI wait for a person to confirm them.

When an action has nothing to do, the step is marked as such and gives a **Reason** you can branch on, for example "The quote is already published" or "Only an accepted quote can become an order". A wrong record or a missing right stops the step with an error such as "Quote not found" or "Not allowed".

## Ask for approval from a flow

Automation's shared **Request approval** step works with quotes and orders. It sends the record to its approvers, exactly like the **Request approval** button, and the flow waits. When approvers finish, the flow continues with the result: approved, rejected or cancelled (for example when someone edits the record meanwhile). If the service does not need approval, the step continues at once. See [Approvals](https://support.rework.com/article/commerce-approvals).

## Example: turn accepted quotes into confirmed orders

1. Trigger: **Quote event**, **Trigger on** = **Quote accepted**, **Quote service** = your quote service.
   
2. Action: **Convert quote to order**, **Quote ID** = the trigger's quote ID, **Order service** = your order service.
   
3. Action: **Confirm order**, **Order ID** = the order from step 2.
   

Every accepted quote now becomes a confirmed order without anyone clicking. If a quote was already converted by hand, step 2 returns the existing order instead of making a second one.

## Good to know

- A change made by a flow never starts that same flow again, so a flow cannot loop on itself.
  
- Orders that come from a connected online store are managed by the store and cannot be confirmed by a flow.
  
- New Commerce steps can take a few minutes to appear in the flow builder.
  

## Troubleshooting

| 
Problem

 | 

Why it happens

 | 

What to do

 |
| --- | --- | --- |
| 

The flow never starts

 | 

The trigger watches another service or event

 | 

Check **Trigger on** and the service in the trigger

 |
| 

"Not allowed"

 | 

The person running the flow lacks the right in Commerce

 | 

Give that person the right in the service, or run the flow as someone who has it

 |
| 

**Create order** says the order already exists

 | 

**Only once per** matched an earlier run

 | 

This is by design. Use a different value if you really want a new record

 |
| 

**Confirm order** does nothing on a portal order

 | 

**Confirm customer requests** is off

 | 

Turn it on in the step

 |
| 

**Convert quote to order** says only an accepted quote can become an order

 | 

The quote is not accepted yet

 | 

Start the flow on **Quote accepted**, or add **Mark quote accepted** first

 |
