Two Service Appointments being created automatically when a Work Order is created in Field Service
Last updated 2017-09-08 ·Reference W-4019616 ·Reported By 2 users
Summary
When a work type is configured to automatically create service appointments, a new work order can result in duplicate appointments being created with a certain configuration of triggers and workflows.
Repro
1) Create a work type with 'Auto-Create Service Appointment' enabled
2) Create a Work Order Trigger that populates work type if it's empty
trigger WorkOrderTrigger on WorkOrder (before insert) {
if (Trigger.isBefore && Trigger.isInsert){
for (WorkOrder wo : Trigger.New){
if (wo.WorkTypeId == null){
wo.WorkTypeId = [select Id from WorkType][0].Id;
}
}
}
}
3) Create a Workflow Rule on "Work Order" object. In Criteria set 'Work Order: Work Type NOT EQUAL TO null'. Create an immediate "Field Update" action that sets the field "Work Order: Description" to formula value "WorkType.Name".
4) Make sure the trigger and workflow are both active.
5) Create a work order without selecting a work type.
6) Notice in the feed of the new work order there are two service appointments created.
Workaround
The workaround would be to change the implementation to avoid using a workflow rule or trigger so that only one is present.
Reported By (2)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.