Skip to main content

Associate a Contract and Service to an Autotask Ticket

This tutorial walks through associating a contract and service to an Autotask ticket created by Email2AT. This is optional, but useful if your Autotask instance requires or benefits from tickets being linked to a specific contract and service for billing or time tracking.


Overview

Autotask uses three related entities for contract/service association:

EntityWhat it is
ContractA billing agreement with a customer (for example, a Managed Services contract)
ServiceA type of work (for example, "Help Desk" or "Hardware - Desktop")
ContractServiceThe join record that links a specific Service to a specific Contract. This is what the ticket actually references.

When you manually create a ticket in the Autotask UI and select a contract, then select a service, Autotask resolves the ContractService join record behind the scenes. When creating tickets via the API, you must resolve it yourself.

The workflow to resolve the ContractService ID is:

  1. Find the Account
  2. Find the Contract on that Account
  3. Find the Service by name
  4. Find the ContractService record that links the Contract to the Service
  5. Create the ticket with the Account ID, Contract ID, and ContractService ID

Related pages:


When to Use This

Use this pattern when:

  • Your Autotask instance requires a contract and service on tickets for billing
  • You want time entries on tickets to automatically apply to the correct contract
  • You have standardized contract structures across your customers (for example, every customer has a "Managed Service" contract with a "Help Desk" service)

If your Autotask instance does not use contract/service associations on tickets, you do not need this.


Step-by-Step Workflow

This tutorial assumes you already have a rule that creates tickets (for example, from the Create Your First Mailbox tutorial). The steps below are inserted before the ticket creation step.

Action 1: Query for the Account

If your workflow already has the Account ID (for example, from the Create Autotask Ticket workflow action), you can skip this step.

  1. Click Add New Action, select API: Query for One Object, click OK
  2. Name the step Find Account
  3. Set Entity Type to Account
  4. Add query conditions as appropriate (for example, by account name or by contact lookup)
  5. In Store results in variable, enter account

Action 2: Query for the Contract

  1. Click Add New Action, select API: Query for One Object, click OK
  2. Name the step Find Contract
  3. Set Entity Type to Contract
  4. Set Only perform this action if: custom.account.id is not empty
  5. Add query conditions:
    • AccountID equals {{custom.account.id}}
    • Status equals Active (or 1, depending on your Autotask)
    • Optionally filter by contract category (for example, ContractCategory equals Managed Service)
  6. In Store results in variable, enter contract

Action 3: Query for the Service

  1. Click Add New Action, select API: Query for One Object, click OK
  2. Name the step Find Service
  3. Set Entity Type to Service
  4. Set Only perform this action if: custom.contract.id is not empty
  5. Add query conditions:
    • ServiceName equals the name of the service you want (for example, Help Desk)
  6. In Store results in variable, enter service
Hard-coding vs. querying

If you always use the same service, you can skip this query and hard-code the service ID directly in the next step. Query the service by name if it varies by customer or if you want the workflow to adapt automatically.

Action 4: Query for the ContractService

This is the join record that links the Contract to the Service.

  1. Click Add New Action, select API: Query for One Object, click OK
  2. Name the step Find ContractService
  3. Set Entity Type to ContractService
  4. Set Only perform this action if: custom.service.id is not empty
  5. Add query conditions:
    • ContractID equals {{custom.contract.id}}
    • ServiceID equals {{custom.service.id}}
  6. In Store results in variable, enter contractService

Action 5: Create the Ticket

  1. Click Add New Action, select API: Create an Object, click OK
  2. Name the step Create Ticket with Contract
  3. Set Entity Type to Ticket
  4. Set Only perform this action if: custom.contractService.id is not empty
  5. Configure the required ticket fields, plus:
FieldValue
AccountID{{custom.account.id}} (unlock the field)
ContractID{{custom.contract.id}} (unlock the field)
ContractServiceID{{custom.contractService.id}} (unlock the field)
StatusNew
PrioritySet as appropriate
QueueIDYour support queue
Title{{email.subject}}
Description{{email.body}}
The contract must belong to the account

Autotask rejects ticket creation if the Contract ID does not belong to the Account on the ticket. The query chain above ensures this by filtering the Contract by Account ID.


Handling Missing Data

If any step in the chain returns no result (no contract, no service, or no ContractService), the subsequent steps are skipped because of the "only perform if" conditions. Add a fallback action that creates the ticket without contract association:

  1. Add another API: Create an Object (Ticket) step after the contract-associated version
  2. Set Only perform this action if: custom.contractService.id is empty AND custom.account.id is not empty
  3. Configure the same ticket fields but omit ContractID and ContractServiceID

This ensures a ticket is always created, with or without contract association.


Key Takeaways

  • ContractService is the join record: the ticket references ContractService, not Service directly
  • Four queries to resolve the chain: Account → Contract → Service → ContractService
  • Guard every step: if any query returns empty, skip downstream steps and fall back to a ticket without contract
  • Contract must match the account: Autotask rejects tickets where the contract does not belong to the ticket's account
  • This is optional: only use this pattern if your Autotask instance requires or benefits from contract/service on tickets