Add DayBack Buttons to Your Salesforce Layouts

Note: The following methods apply to Salesforce Classic Only. In Lightning, buttons cannot run JavaScript, so you'll need to follow the instructions here to add DayBack to a custom tab in Lightning.

Salesforce Specific (Classic Only)

In Salesforce Classic you can add buttons to your Salesforce layouts that can jump directly to a specific item in the calendar, or display all items related to a given record. This allows you to filter the calendar using custom criteria embedded in buttons.

Here are a couple of detailed examples. If you need assistance creating your own, have questions, or want to extend these examples, please get in touch. We love helping our customers with these customizations.


Example 1: A simple button to open an event in DayBack

In this example we'll create a button on your event page that will open up that event in DayBack:

Here's how to do it:

1
From the Setup menu, search for "Event Buttons and Links" in the Setup Quick Find.
2
Click "New Button or Link"
3
Fill out the button's description as shown here:

4
Here's the code you'll need for that large text area:
var m = {!MONTH( DATEVALUE( Event.StartDateTime ) )};
var y = {!YEAR( DATEVALUE( Event.StartDateTime ) )};
var d = {!DAY( DATEVALUE( Event.StartDateTime ) )};
var eventDate = new Date(y, m-1, d);
eventDate = eventDate.toISOString().substring(0,10);
window.location='https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000Pbws&source=Events&date=' + eventDate + '&id={!Event.Id}'
	
Note that this process essentially involves constructing a URL for DayBack. This URL will vary for each Salesforce deployment. To find your specific URL, navigate to DayBack and copy the URL, including the tab name, such as https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000ANpO. Use this URL in the code above, placing it before &source=Events&date= in the last line.
5
Replace the url (through the tab name) in the code above with your DayBack url.
6
Click "Save". You'll add this to a page in the next step.
7
in the Setup Quick Find, search for "Event Page Layouts" and then click on "Edit" beside the layout  on which you'd like to add this button.
8
Drag your new button on to the layout like this:

9
Click "Save".
10
Visit you event layout and try out your new button =).

Example 2: Show this opportunity's tasks in DayBack

A more interesting example that shows how you can include filter and view information in the url to get a very specific result in the calendar:

Here's how to do it:

1
From the Setup menu, search for "Opportunity Buttons and Links" in the Setup Quick Find. Or use the "...Buttons and Links" option for any object in Salesforce.
2
Click "New Button or Link" and follow steps 2 through 6 from Example 1 above to create a new button. Here's the code you'll need for that large text area: 
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}
var result = sforce.connection.query("Select ActivityDate from Task Where WhatId = '{!Opportunity.Id}' AND ActivityDate != NULL Order By ActivityDate");
var record;
if(result.size==="1") {
   record=result.records;
} else if (result.size!=="0") {
   record=result.records[0];
} else if (result.size==="0") {
   alert ( "No tasks in DayBack for this Opportunity" );
}
if(result.size!=="0"){
   var startDate=record.ActivityDate;
   var url = 'https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000ANpO';
   url+='&date='+startDate;
   url+='&filterProjects=' + encodeURIComponent('{!Opportunity.Name}');
   url+='&view=month';
   url+='&source=Tasks';
   window.location=url;
}
Note that this process essentially involves constructing a URL for DayBack. This URL will vary for each Salesforce deployment. To find your specific URL, navigate to DayBack and copy the URL, including the tab name, such as https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000ANpO. Use this URL in the code above, placing it before &source=Events&date= in the last line.
3
Add this button to your opportunities page, following the instructions in steps 7 through 9 in Example 1 above.
4
Visit your opportunities layout and try out your new button =).

A couple cool things about this example that may help you when making your own...

  • Note that in the first line you can load other libraries as part of these buttons, which can be very handy.
  • In the movie that begins this section you'll see that adding filterProjects=... to the URL adds a section to the Filters sidebar in DayBack: a section titled "Project Filters". That will hold any filters you've loaded via URL-buttons like this. These filters can be turned on and off like regular filters and will persist for the duration of the user's session.
  • If you'd like to clear the filters before that, add filterProjects=null to the URL and the Project Filters section will be removed from the sidebar.

Going further: other URL attributes you can use

Note that in the simple example above we didn't include a "view" parameter in the URL. Without one, DayBack will show the event on whichever view you'd last used. In the second example we wanted to see the tasks in a gantt chart type view so we specified a view in the URL like this:

&view=basicHorizon;

You can include a number of parameters like this in order to control DayBack via URL. Here's what's available (note that these are case sensitive):

source

The simple example above included the source as a URL parameter so that DayBack knows to turn on the calendar you're interested in. Without this parameter, the event you're looking for could be in a source that is currently filtered off: without a source specified the "Events" calendar may not be on when you arrive a DayBack.


Format: source=Events where "Events" is the name of your calendar in Administrator Settings / Calendar Sources.


Note that the source parameter doesn't turn off any other calendars by default: it just makes sure that the one you specified is turned on. If you want to turn off all the calendars except the one(s) you're filtering for, call null as your first source like this: source=nulls&source=Events . This is also the syntax for selecting multiple sources at once in the form source=Events&source=Campaigns

date  

Similar to the source, sending the date tells DayBack to navigate to the date you're interested in. Without this, DayBack could be focussed on another month and you wouldn't see what you're looking for.

Format: date=2016-04-11 where the date is in the form YYYY-MM-DD. Only a single date is accepted.

view

This is the name the DayBack tab you'd like to land on, like "Month". 

Format:  view=month  from this list of possible view names.

filterStatuses

Acts like clicking a status in the Status Filters sections of DayBack's sidebar

Format:  filterStatuses=done . Multiple values are accepted like this:  filterStatuses=Done&filterStatuses=Ready

filterResources

Acts like clicking a resource in the Resource Filters sections of DayBack's sidebar,. 

Format:  filterResources=Admin%20User . Multiple values are accepted like this: filterResources=Admin%20User&filterResources=Beth%20Reynolds . You can not pass a folder name this way.

filterContacts

Adds a "Contact Filters" section to the filters tab of the DayBack sidebar containing any people's names passed in. Use the name of the contact here, not their id.

Format:   filterContacts=Lauren%20Boyle . Multiple values are accepted like this: filterContacts=Lauren%20Boyle&filterContacts=Andy%20Young .  To remove the  "Contact Filters" section use  filterContacts=null

filterProjects

Adds a "Project Filters" section to the filters tab of the DayBack sidebar containing any names passed in. You can send in any name that's the related "what" of a calendar item (a campaign, account, case, etc.). 

Format:   filterProjects=University%20of%20Arizona . Multiple values are accepted like this: filterProjects=University%20of%20Arizona&filterProjects=GenePoint .  To remove the  "Project Filters" section use  filterProjects=null

filterText

Fills in the text filte with whatevere string is provided 

Format:   filterText=Some%20Text .  To clear the text filter use  filterText=null



Heading names, like "Contact Filters" that get added to the Filters tab of the sidebar can be changed to suit your business vocabulary. Learn more in the article on  translation.

Available View Names

Here are the possible values for the view parameter, each corresponding to a tab in DayBack:

  • View codes with the word "agenda" in their code name represent the "Schedule" views with time of day scale along the left-hand side.
  • View codes with the word "basic" in their code name represent the "List" views without time scales in the display.
View Name: View Code:
Day Schedule agendaDay
Day List basicDay
Week Schedule agendaWeek
Week List basicWeek
Month List month
Month Schedule agendaDays
Horizon List basicHorizon
Resource Daily basicResourceDays
Resource Schedule agendaResourceVert
Resource Pivot Schedule agendaResourceHor
Resource List basicResourceVert
Resource Pivot List basicResourceHor