I have a Visualforce table. When a user clicks the value in the cell of this VF table, they are directed to a standard opportunity report. In this report, the Close Date range is for 'Current FY' (Jan 16 to Dec 16) and there are 3 field filters and:
- Record Type = always value 'X'
- Opportunity Close Date greater or equal to:
- Opportunity Close Date less or equal to:
For cell A in the Visualforce table, when the user clicks the value in this cell, they are taken to this standard opportunity report and it all works as expected. The URL for the dynamic report is:
https://[SF instance].com/[report Id]?pv1='1/1/2016'&pv2='1/31/2016'
So, everything is working as expected b/c the second parameter (pv1) is marked as 1st Jan 2016, and the third parameter (pv2) is 31st Jan 2016.
For cell B in the Visualforce table, the same thing happens but the report link instead passes in parameters for between 1st Feb 2016 to 29th Feb 2016.
All this is fine except the fact that this report isn't truly dynamic. Once we are in the year 2017, the report links will all need to be updated from '2016' to '2017' else, once clicked, the report won't return any values. I can't use the current list of date literals, because I'm doing a year to date table month on month, and there are no date literals to filter on a particular month (such as FEBRUARY or MARCH etc).
Can I concatenate a date parameter with a date literal, such that I could do: pv1='1/1{!THIS_YEAR}' to represent 1st Jan 2016? I have tried a few different iterations but to no avail.
How can I make this truly dynamic?
=================================================================================== EDIT to include some of the code as per @sfdcfox suggestion:
<apex:page showHeader="true" sidebar="true" controller="BestSoccerPlayers">
<style type="text/css">
<!-- A LOT OF CSS in here - could reference this in a static resource -->
</style>
<div class="tg-wrap"><table id="tg-tzygj" class="tg">
<tr>
<th class="tg-yw42"><b><i><u>[Soccer Club]</u> - [League Level]</i></b></th>
<th class="tg-yw4l"><b>January</b></th>
</tr>
<tr>
<td class="tg-6k2t"><b><u></u> Real Madrid - La Liga</b></td>
<td class="tg-6k2t"><apex:outputText value="{0, number, ###, ### .##}"><apex:param value="{!JanuaryNBYTD}"/><apex:outputLink value="https://cs81.salesforce.com/00O26000000MA16?pv1='1/1/{!currentYear}&pv2='1/31/{!currentYear}"</apex:outputText></td>
</tr></table></div></apex:page>
And then some of the Apex class is:
public without sharing class BestSoccerPlayers{
/*---CONSTANTS---*/
// String SOQL:
/* Date Values */
public String getCurrentYear(){
return (''+System.now().year());
}
public static Double getJanuaryNBYTD() {
sObject record = Database.Query(soql1 + '1')[0];
Double amountX = (Double)record.get('amt')==null?0:(Double)record.get('amt');
return amountX;
}