---
schema_version: "1"
id: 9736003f29c87fdd3c3f0d3cf5dd729cb3bf310c633077c5cadadbd28cd24dd1
title: MaintenancePlan
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_maintenanceplan.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_maintenanceplan.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3e7e772d0300a00f964175aa5c4fdc90ce17595def87a71c8f99dc4fbeb9cbf5
description: Represents a preventive maintenance schedule for one or more assets in field service.
---
# MaintenancePlan

Represents a preventive maintenance schedule for one or more assets in field service.

## Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()

## Special Access Rules

Field Service must be enabled.

## Fields

| Field Name | Details |
| --- | --- |
| AccountId | 
Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The associated account, which typically represents the customer receiving the maintenance service.



 |
| ContactId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The associated contact.



 |
| Description | 

Type

textarea

Properties

Create, Nillable, Update

Description

A brief description of the plan.



 |
| DoesAutoGenerateWorkOrders | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Turns on auto-generation of work order batches for a maintenance plan and prohibits the manual generation of work orders via the Generate Work Orders action. If this option is selected, a new batch of work orders is generated for the maintenance plan on the NextSuggestedMaintenanceDate listed on each maintenance asset, or on the maintenance plan if no assets are included. If a GenerationHorizon is specified, the date of generation is that many days earlier.



 |
| DoesGenerateUponCompletion | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

If both this option and DoesAutoGenerateWorkOrders are set to true, a new batch of work orders isn’t generated until the last work order generated from the maintenance plan is completed. A work order is considered completed when its status falls into one of the following status categories: Cannot Complete, Canceled, Completed, or Closed.

If a maintenance plan covers multiple assets, work orders are generated per asset. If a maintenance asset’s final work order is completed late, its work order generation is delayed, which may cause a staggered generation schedule between maintenance assets.





 |
| EndDate | 

Type

date

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The last day the maintenance plan is valid.



 |
| Frequency | 

Type

int

Properties

Create, Filter, Group, Sort, Update

Description

(Optional) Amount of time between work orders. The unit is specified in the FrequencyType field.



 |
| FrequencyType | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update

Description

(Optional) The unit of frequency:

- Days
- Weeks
- Months
- Years

For example, to perform monthly maintenance visits you need a work order for each visit, so enter 1 as the Frequency and select Months.





 |
| GenerationHorizon | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Moves up the timing of batch generation if DoesAutoGenerateWorkOrders is set to true. A generation horizon of 5 means the new batch of work orders is generated 5 days before the maintenance asset’s (or maintenance plan’s, if there are no assets) NextSuggestedMaintenanceDate. The generation horizon must be a whole number.



 |
| GenerationTimeframe | 

Type

int

Properties

Create, Filter, Group, Sort, Update

Description

(Required) How far in advance work orders are generated in each batch. The unit is specified in the GenerationTimeframeType field.





 |
| GenerationTimeframeType | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update

Description

(Required) The generation timeframe unit:

- Days
- Weeks
- Months
- Years

For example, if you need work orders for six months, enter 6 and select Months.





 |
| LastReferencedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The timestamp when the current user last interacted with this record, directly or indirectly.



 |
| LastViewedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The timestamp when the current user last viewed this record or list view. If this value is null, it's possible that the user only accessed this record or list view (LastReferencedDate), but not viewed it.



 |
| LocationId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Where the service takes place.



 |
| MaintenancePlanNumber | 

Type

string

Properties

Autonumber, Defaulted on create, Filter, Sort

Description

(Read Only) An auto-assigned number that identifies the maintenance plan.



 |
| MaintenancePlanTitle | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

A name for the maintenance plan.



 |
| MaintenanceWindowEndDays | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Days after the suggested service date on the work order that its service appointment can be scheduled.



 |
| MaintenanceWindowStartDays | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Days before the suggested service date on the work order that its service appointment can be scheduled.

The maintenance window start and end fields affect the Earliest Start Permitted and Due Date fields on the maintenance plan’s work orders’ service appointments. For example, if you enter 3 for both the maintenance window start and end, the Earliest Start Permitted and the Due Date will be 3 days before and 3 days after, respectively, the Suggested Maintenance Date on each work order. If the maintenance window fields are left blank, the service appointment date fields list their work order’s suggested maintenance date.





 |
| NextSuggestedMaintenanceDate | 

Type

date

Properties

Create, Filter, Group, Sort, Update

Description

The suggested date of service for the first work order (not the date the work order is created). This corresponds to the work order’s SuggestedMaintenanceDate. You can use this field to enforce a delay before the first maintenance visit (for example, if monthly maintenance should begin one year after the purchase date). Its label in the user interface is Date of the first work order in the next batch.

For example, if you want the first maintenance visit to take place on May 1, enter May 1. When you generate work orders, the earliest work order will list a suggested maintenance date of May 1, and the dates on the later work orders will be based on the GenerationTimeframe and Frequency.

![Important](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note_important.png)

#### Important

Maintenance assets also list a NextSuggestedMaintenanceDate, which is initially inherited from the maintenance plan. If the plan has maintenance assets, this date auto-updates on the maintenance assets after each batch is generated, but doesn’t update on the maintenance plan itself because batch timing is calculated at the maintenance asset level. If the plan doesn’t have maintenance assets, this date auto-updates on the maintenance plan after each batch is generated.















 |
| OwnerId | 

Type

reference

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

The owner of the maintenance plan.



 |
| ServiceContractId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The service contract associated with the maintenance plan. The service contract can’t be updated if any child maintenance asset is associated with a contract line item from the service contract.



 |
| StartDate | 

Type

date

Properties

Create, Filter, Group, Sort, Update

Description

The first day the maintenance plan is valid.



 |
| SvcApptGenerationMethod | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update

Description

The service appointment generation method.

- One service appointment per work order
- One service appointment per work order line item

If your existing maintenance plans have work orders or work order line items associated with them, you can’t change their generation methods. To change pre-existing maintenance plan generation methods, either delete the work orders and regenerate them or delete the maintenance plan and recreate it with the needed generation methods.

If Work Order Generation Method is set to One work order per asset, you can’t set a Service Appointment Generation Method.

If Work Order Generation Method is set to One work order line item per asset, you must select a Service Appointment Generation Method.





 |
| WorkOrderGenerationMethod | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update

Description

The work order generation method.

- One work order per asset
- One work order line item per asset

If your existing maintenance plans have work orders or work order line items associated with them, you can’t change their generation methods. To change pre-existing maintenance plan generation methods, either delete the work orders and regenerate them or delete the maintenance plan and recreate it with the needed generation methods.

If Work Order Generation Method is left as None, the generation is defaulted to one work order per asset.

When One work order line item per asset is set, and all maintenance assets have the same Next Suggested Maintenance Date on the maintenance plan, they are grouped in one work order. However, if maintenance assets have different Next Suggested Maintenance Dates, multiple work orders are created for each date.

If Work Order Generation Method is set to One work order per asset, you can’t set a Service Appointment Generation Method.





 |
| WorkOrderGenerationStatus | 

Type

picklist

Properties

Defaulted on create, Filter, Group, Nillable, Restricted picklist, Sort

Description

(Read Only) Indicates the status of work order generation:

- NotStarted—the default value, work order generation has not started
- InProgress—work order generation is underway
- Completed—work order generation is complete
- Unsuccessful—it was not possible to generate work orders

You can generate only one batch at a time.



 |
| WorkTypeId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The associated work type. Work orders generated from the maintenance plan inherit its work type’s duration, required skills and products, and linked articles. Maintenance assets covered by the plan use the same work type, though you can update them to use a different one.



 |

## Associated Objects

This object has the following associated objects. If the API version isn’t specified, they’re available in the same API versions as this object. Otherwise, they’re available in the specified API version and later.

[MaintenancePlanChangeEvent](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_change_event.htm "A ChangeEvent object is available for each object that supports Change Data Capture. You can subscribe to a stream of change events using Change Data Capture to receive data tied to record changes in Salesforce. Changes include record creation, updates to an existing record, deletion of a record, and undeletion of a record. A change event isn’t a Salesforce object—it doesn’t support CRUD operations or queries. It’s included in the object reference so you can discover which Salesforce objects support change events.") (API version 48.0)

Change events are available for the object.

[MaintenancePlanFeed](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_feed.htm "StandardObjectNameFeed is the model for all feed objects associated with standard objects. These objects represent the posts and feed-tracked changes of a standard object.")

Feed tracking is available for the object.

[MaintenancePlanHistory](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_history.htm "StandardObjectNameHistory is the model for all history objects associated with standard objects. These objects represent the history of changes to the values in the fields of a standard object.")

History is available for tracked fields of the object.

[MaintenancePlanOwnerSharingRule](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_ownersharingrule.htm "StandardObjectNameOwnerSharingRule is the model for all owner sharing rule objects associated with standard objects. These objects represent a rule for sharing a standard object with users other than the owner.")

Sharing rules are available for the object.

[MaintenancePlanShare](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_share.htm "StandardObjectNameShare is the model for all share objects associated with standard objects. These objects represent a sharing entry on the standard object.")

Sharing is available for the object.