1

We are trying to get auto generation of Work Orders and Service Appointments working, however when we try to generate Work Orders with the following generation types it always fails:

Work Order Generation: One Work Order Line Item per Asset Service Appointment Generation: One Service Appointment per Work Order

After numerous tests I've narrowed it down to being caused by a specific validation rule. Deactivating the rule allows Generation of Work Orders and Service Appointments to complete successfully. The rule is as follows:

AND(
    ISBLANK( Street ),
    ISBLANK( City ),
    ISBLANK( State ),
    ISBLANK( PostalCode ),
    ISBLANK( Country )
   )

The strange part is that once turned off when I checked out the SA that had been auto generated, it had it's address filled out completely (due to SalesForce native automation). In theory, it should not have triggered the validation rule.

Things I have tried:

With the validation rule activated, I have tried creating a Process that would fill in the SA's address based off the WO's Address on creation. Result: Unsuccessful Generation

Changing the validation rule to not trigger if the SA was created off a Maintenance Plan work order by editing it to be:

AND(
    ISBLANK( Street ),
    ISBLANK( City ),
    ISBLANK( State ),
    ISBLANK( PostalCode ),
    ISBLANK( Country ),
    ISBLANK(Work_Order_Hidden__r.MaintenancePlanId)
   )

Result: Unsuccessful Generation

Honestly, this exercise has made me question whether or not the validation rule is even necessary as it appears that no matter how I create a Service Appointment , it has an address but let's assume it is necessary: Why is it being active breaking Maintenance Plan Work Order Generation when from all accounts and purposes it shouldn't be triggered by these SAs? My only thought is that some how whatever is filling in the Address on the SA is happening after Validation Rules are being resolved but this doesn't seem right to me.

1
  • if the address fields are derived from a parent sobject, you could use a before insert trigger to populate them so the VR rules pass; or if all SAs are auto-generated, you could make the VR rule fire only on NOT(ISNEW()). See also The address where the appointment is taking place. The address is inherited from the parent record if the parent record is a work order or work order line item. - hence occurs after SA is saved and before VR
    – cropredy
    Jan 4, 2020 at 4:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.