Add DayBack Buttons to Your Salesforce Layouts
Salesforce Specific (Classic Only)
You can jump right to a specific item in the calendar, or show all the items related to a given record, by adding DayBack buttons to your own Salesforce layouts. This effectively lets you filter the calendar using your own criteria embedded in buttons.
Note: These 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.
A couple detailed examples follow. If you have trouble making your own, have questions, or really want to extend what you see here, please get in touch. We love making these for our customers.
In this article
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 is basically building a URL for DayBack. This url will be different for every Salesforce deployment. To find yours, just navigate over to DayBack and take a look at the url; copy that text including the tab name like this: "https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000ANpO". You want to use that in the code above, 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 is basically building a URL for DayBack. This URL will be different for every Salesforce deployment. To find yours, just navigate over to DayBack and take a look at the URL; copy that text including the tab name like this: "https://dbk.na30.visual.force.com/apex/DayBack?sfdc.tabName=01r36000000ANpO". You want to use that in the code above replacing the URL in the line beginning "var url". - 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. 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:Name of view -- Corresponding tab in DayBack basicDay -- Simple Day View agendaDay -- Day view with times down the left side basicWeek -- Simple Week View agendaWeek -- Week view with times down the left side month -- Month view agendaResourceVert -- Resource tab, "Schedule" with times down the left side agendaResourceHor -- Resource tab, "Pivot Schedule" with times across the top basicResourceVert -- Resource tab, "List" list view basicResourceHor -- Resource tab, "Pivot" list view basicHorizon -- Horizon view (Gantt Chart) |
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 . |
|