0

Is it possible to create dynamic values for a picklist from a standard picklist option and not in a VF page ?

eg: I want to create a field Close Date as a picklist with Q1/Y1, Q2/Y1, Q3/Y1, Q4/Y1, Q1/Y2, Q2/Y2, Q3/Y2, Q4/Y2 where Y1 – is the current year (i.e. ‘12’ for 2012) and Y2 is the next year (i.e. ‘13’).

Rao
  • 16,691
  • 13
  • 68
  • 108

3 Answers3

2

Sounds like insane database design ;)

They're not really related, so why don't you simply create "Year" and "Quarter" picklists? You can always concatenate it later in formula field or something if you wish:

TEXT(Year__c) & ' ' & TEXT(Quarter__c)

Or make a normal date field with help text "Dear user, actual day doesn't matter, just pick anything in proper quarter" and again - format it nicely in formula. Something like this (untested!):

'Q' & IF(MONTH(Date__c) <= 3, '1',
    IF(MONTH(Date__c) <= 6, '2',
        IF(MONTH(Date__c) <= 9, '3',
            '4'
        )
    )
) & ' ' & TEXT(YEAR(Date__c))
eyescream
  • 24,045
  • 5
  • 55
  • 92
  • I like the idea of two separate fields for Year and Quarter. Furthermore, instead of a formula, you could create a dependency so that when the year is selected, it restricts the Quarter picklist to Q1YY, Q2YY, etc – James Loghry Nov 20 '12 at 20:37
0

I imagine you could schedule an automation job that would periodically update the values. You can update these values via the Metadata API and that is something that can be run from a command line. In addition to updating the picklist values you will also need to update which values each Record Type uses.

Keep in mind that if you ever need to modify those records in the future that your picklist option may no longer be there.

Edit: Answer updated to change Apex to Metadata API.

Mike Chale
  • 13,364
  • 6
  • 47
  • 89
0

You could create a Workflow Field update that fires upon close. The field update could update a text field with something like the following:

IF(Month(Today()) <= 3, "Q1 "+TEXT(Year(Today())),IF(AND(Month(Today()) >3, Month(Today()) <=6), "Q2 "+TEXT(Year(Today())),IF(AND(Month(Today()) >6, Month(Today()) <=9), "Q3 "+TEXT(Year(Today())),"Q4 "+TEXT(Year(Today())))))

This example would update the field with "Q{Current Quarter 1,2,3,4} {Current Year}"

Justin J Carlson
  • 703
  • 2
  • 12
  • 19