
Taking advantage of DayBack’s custom actions, significant customizations can be made to the calendar to reflect Lightning Scheduler’s somewhat complex data model for Service Appointments and Service Resources.
#LIGHTNING SCHEDULER SALESFORCE HELP CODE#
The test class for code coverage on both of these triggers can be downloaded here. ResourceScheduler_InsertUpdateTrigger.txt This will ensure the related Assigned Resource records and DayBack’s stay in sync without any extra work for the user.

For this, Apex Triggers can be used on the Assigned Resource object to capture if an Assigned Resource is created, updated, or deleted.
#LIGHTNING SCHEDULER SALESFORCE HELP UPDATE#
ResourceScheduler_OnEventSave.js Resource Scheduling – Edits Made Outside of DayBackĪlthough DayBack’s On Event Save action will update Salesforce data accurately, what about edits going the other way? If Appointments are being created outside of DayBack with Assigned Resources, DayBack’s custom field must be updated to reflect the resource assigned. Here’s the code for an On Event Save action to maintain the Assigned Resources records based on a resource edit in DayBack. This keeps the On Save Action itself from being more complicated than it already is. Since the On Resources Fetched action has written both the Service Resource Name and Id to DayBack, the On Save action can find the Service Resource Ids needed from memory rather than asking Salesforce for the Ids. Fortunately, Assigned Resource records can have the Service Resource Id updated, so deletion and creation are not always required during an edit. And if the number of resources has changed, then the Assignment records will need to be added or deleted accordingly to keep everything in sync. When there are the same number of Assignments, then the current Assigned Records can be looped through with the new resource values. If the appointment already exists, but the resources are changed in DayBack, then the existing Assignments need to be compared to the new ones specified in DayBack. When the appointment is examined on its native layout, the Assigned Resources section is then populated.Īssigned Resources are created and updated from DayBack Once each join record has been created, the On Save action is allowed to complete, showing the creation toast notification record. Once the Appointment is created successfully, then the Assigned Resources can be created. Since the Assigned Resource relationship to the Service Appointments is a Master-Detail relationship in Salesforce, the Appointment must exist to create the Assignments. If this is a new assignment, then the appointment needs to be created first. When this field is edited in DayBack, the On Save action will do the following. This will be mapped as the resource field in DayBack. This is a little tricky, but certainly doable.Ī new custom text area field will need to be added to the Service Appointment object. The On Save action needed here will need to create and update the Assigned Resources records instead of just updating a single key field. Instead of a Look-Up or Master-Detail, it uses a join table called Assigned Resources, which allows multiple resources to be related to a single Service Appointment. However, the relationship between Service Appointments and Service Resources is more complex. The Looking Up A Resource ID By Name (Salesforce) example here is a good example of implementing this technique. With the id, the related key field is then updated accordingly. In these cases, a formula field can be added to the object to display the related value, and then an On Event Save Custom Event Action can be used to look up the id. ResourceScheduler_LoadResources.js Resources in the Salesforce Lightning Scheduler Join TableĭayBack can reflect related fields for resources relatively easily when the relationship is a standard Look-Up or Master-Detail. Here’s the code for an On Resources Fetched action to load Lightning Scheduler’s Service Resources by Service Territory. This will save some work later on when DayBack needs to edit a Service Appointment’s resource information. The other benefit from loading the resources from Salesforce Data is that both the resource name and resource id can be captured as part of this process. Resources and folders loaded dynamically from Salesforce data
