I need to create a select box with options showing the current quarter and previous 11 quarters in my Vf page.
I dont want to hardcode them as the values would change with a new quarter. This should always default to current quarter.
Any pointers would be helpful
Thanks
Use apex:selectList with selectOptions to display:
The controller could look like the following:
To automatically generate the option values, I would use Datetime methods: now() to grab the current date, month() and year() to extract the month and year, and maybe use a Map to lookup the quarter by month, or divide the month number by three and use ceil() to get the current quarter.
To create the previous 11 quarters, use addMonths() with a negative value, three months at a time inside a loop.
If you are not using calendar quarters you may be able to use SOQL to query the Period object. You can definitely determine your fiscal year start month: