How to Create a Date Picker Pre-Selection Page in Composer
This technique allows you to create a Visualforce page that prompts a user for ‘Start Date’ and ‘End Date’ values that can be passed to corresponding filters on a Salesforce Report or Conga Query.
Your Date field in Salesforce MUST be a Date Field, NOT a Date/Time Field.
The user can then select the start and end dates before clicking “Launch”. The date values are then substituted into the URL and the browser is re-directed to the Composer dialog.
Visualforce Page
<apex:page language="en" showHeader="false"
sidebar="false" standardStylesheets="true" ><link type="text/css"
href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/cupertino/jquery-ui.css"
rel="stylesheet" /><script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script><script
type="text/javascript"
src="https://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-en-GB.js"></script><script
type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script><apex:pageBlock
title="Please select the start and end dates:"><p>Start Date:<br
/><input id="startDate" type="textbox"/></p><p>End Date:<br
/><input id="endDate"
type="textbox"/></p><!--$(selector).datepicker({defaultDate: new
Date(2009, 1-1, 26)});$(selector).datepicker({defaultDate:
'01/26/2009'});$(selector).datepicker({defaultDate:
+7});$(selector).datepicker({defaultDate: '+1m -1d'});--><script
type="text/javascript">$(function() {$("#startDate").datepicker(); // You must
leave this
line$("#startDate").datepicker($.datepicker.regional['en-US']);$("#startDate").datepicker('setDate',
'-1w'); // This is optional});s</script><script
type="text/javascript">$(function() {$("#endDate").datepicker(); // You must leave
this
line$("#endDate").datepicker($.datepicker.regional['en-US']);$("#endDate").datepicker('setDate',
'+1w'); // This is optional});</script><br /><input type="button"
onclick="launchConga()" value="Launch" /><script>function launchConga(){var
startDate = document.getElementById("startDate");var endDate =
document.getElementById("endDate");// For Queries...var sDate = new
Date(startDate.value);var eDate = new Date(endDate.value);var startDateForQueries =
sDate.getFullYear() + "-" + ("0" + (sDate.getMonth() + 1)).slice(-2) + "-" + ("0" +
sDate.getDate()).slice(-2);var endDateForQueries = eDate.getFullYear() + "-" + ("0" +
(eDate.getMonth() + 1)).slice(-2) + "-" + ("0" + eDate.getDate()).slice(-2);var
qsIndex = window.parent.location.href.indexOf('?') + 1;var qs =
window.parent.location.href.substring(qsIndex, window.parent.location.href.length);qs
= unescape(qs);// Use these lines if you're passing to Reports:qs =
qs.replace(/{StartDateR}/g , startDate.value);qs = qs.replace(/{EndDateR}/g ,
endDate.value);// Use these lines if you're passing to Queries:qs =
qs.replace(/{StartDateQ}/g, startDateForQueries );qs = qs.replace(/{EndDateQ}/g,
endDateForQueries );window.parent.location.href = "https://composer.congamerge.com?"
+ qs;}</script></apex:pageBlock></apex:page>
Sample Button (Account)
/apex/DatePicker ?sessionId={!API.Session_ID} &serverUrl={!API.Partner_Server_URL_80} &id={!Account.Id} &ReportId=[DynamicOpps]00OA00000044TEO?pv0={StartDateR}~pv1={EndDateR}