When working with the Multi Resource Calendar, you might want to link to a specific calendar directly. This is possible using URL parameters with the Multi Resource Calendar.

Multi Resource Calendar page parameters

While the Start parameter does specify where the calendar starts, if the view being linked to is 'Week' or 'Month', the page being displayed will start at the start of the Week or Month that Start is contained in.

Parameter Name

Required?

Description

calendar

Yes

The name of the Calendar record where the configuration should be loaded from.

recordId

No

One or more ID's of the Resource, Staff or Group records you want to display the calendar for. These resources should exist and be non Virtual and of the same type as the calendar. If the id of a parent resource is provided, all its children will also be loaded. This parameter overrides any user defined filters.

start

No

The Start date of the calendar. Should be in either the ISO 8601 format or the RFC 2822 format.

The time part is optional, but can be included to allow for easy use of DateTime fields. Special value TODAY will set Start to the current date of the user's device.

view

No

The unique name of a View that is attached to the calendar of the type of Resource being displayed. if the view could not be found, the default View wil be selected

rsv

No

The id of a reservation. If provided the calendar will focus on this reservation and highlight it for 5 seconds.

lightning

No

Indicate if Booker25 is running in Lightning Experience context or not. Pass true if in Lightning Experience and false otherwise. This is required, because when Booker25 is embedded it has no way of detecting this context by itself. If not passed, Booker25 wil assume Classic context, and links to Visualforce pages will not open correctly for users in Lighting Experience.

prototypeReservation

No

A JSON object that represents a reservation. This reservation will be used as a template when new reservations are created on the calendar. This allows you to pre-populate fields. This can be useful for automatically linking new reservations to the record on which you are embedding the calendar.

preserveIdOrder

No

If you include preserveIdOrder=true, the order of the ids passed in the recordId parameter will be maintained on the calendar. The default value is false, which means that the calendar applies its own ordering.

Multi Resource calendar page structure and naming

The Multi Resource Calendar consists of two separate pages:

Page name

description

B25__MultiResourceCalendarWrapper

The main page for the Multi Resource Calendar. This page includes the Salesforce header and looks like a Salesforce page. Use this in your URL when linking to the calendar in both Salesforce Classic and Lightning.

B25__MultiResourceCalendar

The page wrapped by B25__MultiResourceCalendarWrapper. This page contains all the actual logic for the Multi Resource Calendar. Use this page when embedding the calendar in a detail page, or somewhere where the Salesforce header is already on the page.

Older versions of booker25 used different pages and three of these pages are still used for the resource staff and group tabs.

Page name

description

classic_calendar

Used for the resource calendar tab loads the calendar with the configuration of the calendar Named Resources

ClassicGroupCalendar

Used for the group calendar tab loads the calendar with the configuration of the calendar Named Groups

ClassicStaffCalendar

Used for the staff calendar tab loads the calendar with the configuration of the calendar Named Staff

lightning_calendar

Calendar page without the salesforce header loads the calendar with the configuration of the calendar Named Resources

GroupCalendar

Calendar page without the salesforce header loads the calendar with the configuration of the calendar Named Groups

StaffCalendar

Calendar page without the salesforce header loads the calendar with the configuration of the calendar Named Staff

Linking to a specific calendar

Lightning Considerations

When linking to the multi resource calendar from Lightning Experience, loading the page might result in the page opening without the Lightning header. When this happens append /one/one.app#/alohaRedirect to the front of the URL.

Doing this,

/apex/B25__MultiResourceCalendarWrapper?recordId=XXXXXXXXXXXXXXXX&calendar=Resources

becomes

/one/one.app#/alohaRedirect/apex/B25__MultiResourceCalendarWrapper?recordId=XXXXXXXXXXXXXXXX&calendar=Resources

You can link to a specific calendar by specifying the View and Start date in the URL. For example, to create a link to the calendar from a Reservation detail page that wil show the Multi Resource Calendar on the week where the reservation starts proceed as follows:

  1. Go to the View record that specifies the week view on the Multi Resource Calendar and copy the unique identifier, for example: day

  2. Go to Salesforce Setup and create a new button or link on the Reservation object

  3. The URL to be used in this example would be

     /apex/B25__MultiResourceCalendarWrapper?recordId={!B25__Reservation__c.B25__Resource__c}&view=day&start={!TEXT(B25__Reservation__c.B25__Start__c)}&calendar=Resources
    
    
  4. Save the new link and add it to the Reservation Page Layout

  5. The button / link should open the calendar on the week that the reservation starts, for the resource the reservation was made in.

Specifying multiple recordIds

You can specify multiple record ids to display on the calendar, to do this separate the record ids using commas for example:

/apex/B25__MultiResourceCalendarWrapper?recordId=XXXXXXXXXXXXXXXX,YYYYYYYYYYYYYY,ZZZZZZZZZZZZZZZZZ&view=day&calendar=Resources

Embedding the Multi Resource Calendar in a VisualForce page

It is possible to embed the Multi Resource Calendar into your own VisualForce pages and in the detail pages in the standard Salesforce ui.

In this example, we will show how to make a page that can be embedded into a Contact detail page. This Contact record has a lookup to the Staff record that represents this Contact, named Staff__c. This page will show the Contact's calendar for the current week.

This example page allows you to set the parameters on a javascript object and let booker25 handle parsing the url and passing the extra parameters down to the calendar.

ContactDetailCalendar visualforce page
<apex:page showHeader="false" sidebar="false" applyBodyTag="false" standardController="Contact">
    <style>
        html,body{height:100%}iframe.page-iframe{height:100%;width:100%;position:absolute;top:0;bottom:0;left:0;right:0}html body.sfdcBody{padding:0 !important}#contentWrapper{height:calc(100% - 152px)}.outerNoSidebar{height:100%;padding:0 !important}.noSidebarCell{padding:0 !important}.bodyDiv{overflow:hidden !important}
    </style>
    <iframe id='page-iframe' class="page-iframe" src="" frameborder="0"></iframe>
    <script>
    	var baseUrl = "{!$Page.B25__MultiResourceCalendar}";
    	var parameters = {};
    	parameters.recordId = '{!Contact.Staff__c}';
    	parameters.start = 'TODAY';
    	parameters.view;
    	parameters.rsv;
    	parameters.calendar = "Staff";
    	parameters.lightning;
		parameters.prototypeReservation;
    	var d=function(){var e={},a=document.location.search.substring(1);return a?(a.split("&").forEach(function(a){var r=a.split("=");1===r.length?e[r[0]]="":e[r[0]]=decodeURIComponent(r[1])}),e):e},f=function(e){var a="";for(var r in e)e.hasOwnProperty(r)&&(a+=a?"&":"?",a+=r+"="+encodeURIComponent(e[r]));return a},r=function(e,a){if(!c()&&"undefined"!=typeof history&&void 0!==history.replaceState){if(window.location!=window.parent.location&&"function"==typeof window.parent.postMessage){var r={cmd:"B25::updateParameter",parameter:e,value:a};window.parent.postMessage(r,"*")}var t=d();t[e]=a;var n=f(t),o=document.location.pathname+n;history.replaceState({},"",o)}},c=function(){return"undefined"!=typeof sforce&&void 0!==sforce.one},t=function(e){e.origin===window.location.origin&&"object"==typeof e.data&&"B25::updateParameter"===e.data.cmd&&r(e.data.parameter,e.data.value)};window.addEventListener("message",t,!1);var n=d();for(pro in parameters)parameters.hasOwnProperty(pro)&&parameters[pro]&&(n[pro]=parameters[pro]);var o=f(n),i=document.getElementById("page-iframe");i.src=baseUrl+o;
	</script>
</apex:page>

Note how we used the B25__MultiResourceCalendar instead of B25__MultiResourceCalendarWrapper, to avoid the standard Salesforce header being shown within the Contact detail page. Also passing TODAY to the start parameter is optional, since when no parameter is passed it defaults to the current date.

Specifying a prototype reservation

When creating a Reservation on an embedded calendar, you may pre-populate fields on the Reservation with information from the record on which the calendar has been embedded. Booker25 does this by creating a "Prototype Reservation".

There are multiple ways to build the JSON required for the Prototype Reservation:

  1. Build the JSON in VisualForce.

  2. Build the JSON in a controller

Build the JSON in VisualForce

Using the code snippet below, and on a VisualForce page that references the Contact Standard Controller, you can create a JSON object in VisualForce using the fields on the Contact object:

parameters.prototypeReservation = '{"B25__Contact__c" : "{!Contact.Id}"}';

Build the JSON in a controller

For a more complex Prototype Reservation, you can define a Controller Extension and then output the Reservation JSON on the page:

public class EmbededOpportunityCalendarExtension {

    private final Opportunity opp;
    
    public EmbededOpportunityCalendarExtension(ApexPages.StandardController stdController) {
		// Add the fields required for the reservation prototype
        stdController.addFields(new List<String>{'AccountId', 'Probability'});
        this.opp = (Opportunity) stdController.getRecord();
    }

    public String getPrototypeReservation() {
        B25__Reservation_Status__c reservationStatus = EmbededOpportunityCalendarExtension.getReservationStatusBasedOnProbability(this.opp.Probability);
		B25__Reservation__c prototypeReservation = new B25__Reservation__c(
			B25__Opportunity__c = this.opp.Id,
			B25__Account__c = this.opp.AccountId,
			B25__Status__c = reservationStatus.Id
		);
        return JSON.serialize(prototypeReservation);
    }

	private B25__Reservation_Status__c getReservationStatusBasedOnProbability(Decimal probability) {
        String statusName = '';
		if (probability > 75) {
            statusName = 'Definite';
        } else {
            statusName = 'Option';
        }
        return [SELECT Id FROM Reservation_Status__c WHERE Name= :statusName];
	}
}

Output on the VisualForce page that references the Opportunity Controller Extension:

parameters.prototypeReservation = '{!prototypeReservation}';

Bookmarking calendars and linking calendars

This functionality only works in Salesforce Classic due to Salesforce limitations.

The Multi Resource Calendar can be bookmarked and linked, as the app keeps the URL up to date with the current the View and Start parameters. This means that if you copy the current URL and distribute it to other users, they wil get the same calendar you are viewing (if they are logged in to Salesforce and their Permissions allow for this).

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.


Related issues