1

Can any one help me on this .How to write an logic or the Condition to get the current and future year data displayed in Visual force page PDF.I have written a condition where it gives the current data,looking for the logic for the future years.Any help very much appreciated.

COde

if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

        }

       } 

Which displays the data of the current year. In similar way can go for an if condition for the years to get the past,present and future data display in a visual force page.

    public integer previousyear{get;set;}
    public integer currentyear{get;set;}
    public integer futureyear{get;set;}
    previousyear = date.today().year()-1;
    currentyear = date.today().year();
    futureyear = date.today().year()+1;

    if ((year==previousyear||year==currentyear||year==futureyear)){
                    quarterMap = Quarter1;
                     system.debug('quarterMap@@@@@@@@'+quarterMap);
                    amountMap = Amount1;
                if (quarterMap.containskey(prodName)) {
                    quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                    amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
                } else {
                    quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                    amountMap.put(prodName, oppforecast.gmod__Amount__c);

            }

           } 

or can I club both the statements in this way :

 if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')
&&
(year==currentyear ||year==currentyear||year==futureyear))

I shall appreciate your help.

  • Your question seems to be very simple but somehow I am now able to get it. What exactly do you want to achieve? – Santanu Halder May 4 '15 at 11:19
  • @ Santanu Halder:I get the data for the current year (2015)and the requirement is even for the future years (say 2016,2017,2018......) the data should get displayed.I mean the logic should be written in the way so tat the data can be achieved for the past,present and future.Any help very much appreciated. – nikkey May 4 '15 at 11:28
  • Your 2nd block of code should do the job. Its checking if the year is previous year or current year or future year.. This seems right! – Santanu Halder May 4 '15 at 11:47
  • @ Santanu Halder:I mean I need to write an another code as first one and call the wrapper class again.so the for loop gets repeated n no of times.can we club the 1st and 2nd condition in a if statement. – nikkey May 4 '15 at 11:53
  • Tell me if this is right.. Fetch the data for all months of previous year, all the months of Future year and only Jan, Feb & Mar for current year? Is this what you want to pull? – Santanu Halder May 4 '15 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.