Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Booker25 multi dimension calendars have a context menu when the user clicks on a dimension record

...

This menu can be customised customized by following the following steps.

  1. Create an Apex class that implement the System.Callable interface. For an example, see the code below.

  2. Click on Setup and search for Custom Settings

  3. Click on Manage next to System_Settings

  4. Click New

  5. For the name specify Calendar Context Menu Class

  6. Fill in the name of the apex class in the String value field

  7. Click Save

Callable class parameters and return type

The callable class has two parameters a String specifying the action and a Map<String, Object> with parameters
For the custom context menu the action wil will be contextMenu.
The parameter map will contain one entry defaultContextMenu this entry is a List of context menu items.

...

Key name

Type

Description

uniqueId

String

Unique id not . Not required but provided by for the default items so they can be identified.

label

String

The label shown in the context menu.

urlTemplate

String

The url that should be opened if the user clicks this item. This template can include a merge field {dimensionRecordId} this wil . This will be replaced with the id of the dimension record the user selected.

hideIfNotReservable

Boolean

If true the entry will not be shown on non reservable dimension objects.

booker25AdminsOnly

Boolean

If true the entry wil will only be visible if the user has the B25_Admin permission set.

availableForDimensions

List<String>

The names of the dimensions where this entry should be show. If left empty it wil will be shown on all dimensions.

isBooker25CustomAction

Boolean

Some booker25 Booker25 actions are not just opening urls for these this property wil will be set to true and booker25CustomAction wil will be set to specify the custom action.

You can not add additional custom actions but any context entries with this property set to true and an existing custom action selected wil will work.

booker25CustomAction

String

The custom action this button should run. Currently two difference different actions are available. expandReservationGroups and collapseReservationGroups. expandReservationGroups wil :

  • expandReservationGroups will expand any groups of reservations that are collapsed and

wil
  • will only be visible if there are any collapsed groups.

  • collapseReservationGroups

wil
  • will collapse any expanded reservation groups and

wil
  • will only be visible if there are any expanded groups.

Default context menu

The default context menu consists of the following items

unique id

Type

Additional conditions

Description

SingleCalendarLink

Url

hideIfNotReservable

Opens the single calendar for the selected dimension record.

ViewInSalesforce

Url

None

Opens the dimension record in salesforce

ViewInBooker25

Url

Dimension B25__Resource__c and booker25AdminsOnly

Opens the dimension record in the booker25 UI

ExpandReservationGroups

Action

Only visible if there are collapsed groups in the dimension record row

Expands any reservation groups in the selected dimension record.

CollapseReservationGroups

Action

Only visible if there are expanded groups in the dimension record row

Collapses any reservation groups in the selected dimension record.

...

Example

This example implementation updates the view calendar ‘View Calendar’ link to go to a specific calendar implementation with uniqueName customSingleCalendar.

It also removes the View ‘View in salesforce Salesforce’ and View ‘View in Booker25 Booker25’ links.

Code Block
languagejava
global with sharing class CustomContextMenu implements System.Callable {

    global Object call(String action, Map<String, Object> parameters) {
    
        if (action != 'contextMenu') {
            return null;
        }
        
        List<Map<String, Object>> defaultMenu = (List<Map<String, Object>>) parameters.get('defaultContextMenu');
        
        // Update the single resource calendar link
        for (Map<String, Object> menuItem : defaultMenu) {
            if (menuItem.get('uniqueId') == 'SingleCalendarLink') {
                String calendarName = 'customSingleCalendar'; // this must be the uniqueName of an existing calendar record
                String urlTemplate = Page.B25__SingleResourceCalendarWrapper.getUrl() + '?recordId={dimensionRecordId}&calendar=customSingleCalendar' + calendarName;
                menuItem.put('urlTemplate', urlTemplate);
            }
        }
        
        // remove the view'View in salesforceSalesforce' and view'View in booker25Booker25' links
        Integer i = 0;
        while (i < defaultMenu.size()) {
            String uniqueId = (String) defaultMenu[i].get('uniqueId');
            if (uniqueId == 'ViewInSalesforce' || uniqueId == 'ViewInBooker25') {
                defaultMenu.remove(i);
            } else {
                i += 1;
            }
        }
        
        return defaultMenu;
    }
}