When setting up resource titles you might want to calculate the value dynamically based on values in the resource and what reservations are currently visible on the calendar.
Using dynamic resource titles this is possible.
Only use dynamic titles on the multi resource calendar when there is no other way to achieve the same functionality (by using a formula field for example).
|
Activate your implementation on a calendar by creating a Resource Title record for it.
The DynamicResourceTitles interface enforces one method: calculateResourceTitles. This method takes a B25.Util_PluginManager.DynamicResourceTitleData object as input. This object contains the following information:
Property | Type | Description |
---|---|---|
startDatetime | Datetime | The start of the current view that the user sees on the calendar. |
endDatetime | Datetime | The end of the current view that the user sees on the calendar. |
resourceToVisibleReservations | Map<Id, List<Id>> | Map of resource ids to a list of the ids of the reservations that are currently visible to the user. This list will also contain any unshared reservations that are visible to the user (if "Show greyed out blocks on the calendar for unshared reservations" is enabled). If you want to query the unshared reservations as well as the shared ones the implementation class needs to be without sharing. |
resourceToHiddenReservations | Map<Id, List<Id>> | Map of resource ids to a list of the ids of the reservations that are currently hidden from the user by reservation filters on the calendar. |
Using this information the method should calculate the values for each resource and return a Map<Id, String> containing a mapping of the resource to the value that should be displayed on the calendar.
The following example displays the number of currently visible reservations in each resource.
global with sharing class DynamicTitleImplementation implements B25.Util_PluginManager.DynamicResourceTitles { global Map<Id, String> calculateResourceTitles(B25.Util_PluginManager.DynamicResourceTitleData dataObj) { // all the reservations that are currently visible to the user, mapped to their resource Map<Id, List<Id>> visibleReservations = dataObj.resourceToVisibleReservations; // the values we are going to return, mapped by resource Map<Id, String> output = new Map<Id, String>(); // loop over each resource for (Id resourceId : visibleReservations.keySet()) { // get the visible reservations in the current resource List<Id> reservationIds = visibleReservations.get(resourceId); // how many are there? Integer numberOfReservations = reservationIds.size(); // add the result to the output map output.put(resourceId, String.valueOf(numberOfReservations)); } return output; } } |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|