Are you really going to make we write this?
Last Updated on Wednesday, 21 January 2009 11:20 Written by Steve Wednesday, 21 January 2009 11:20
Salesforce.com, why do you make me write this just to get the text value from a picklist?
CASE(
Parsed_Home_Street_Type__c,
"Aly","Aly",
"Ave","Ave",
"Baum","Baum",
"Blvd","Blvd",
"Cir","Cir",
"Close","Close",
"Court","Court",
"Cres","Cres",
"Dvrsn","Dvrsn",
"Dr","Dr",
"Grn","Grn",
"Hill","Hill",
"Hwy","Hwy",
"Mews","Mews",
"Ln","Ln",
"Pkwy","Pkwy",
"Pssge","Pssge",
"Pl","Pl",
"Quay","Quay",
"Rd","Rd",
"Row","Row",
"Sq","Sq",
"St","St",
"Wlk","Wlk",
"Way","Way",''
)
I think platform creators, like Salesforce.com, should judge themselves on if they allow their customers to write good code. This is not good code. See if you can spot the inefficiency.
And there is nothing I can do about it. It’s the only way to get the text value of a picklist. Salesforce.com owns the platform–I have to wait for them to change it.
The first inkling this will get fixed came in the Spring ’09 release which has a fix when using picklists in Validation Rules. But I want to use picklists in formula fields, so until at least the next release, as Louis C.K. would say, “I’m writing CASE statements with hard-coded values like an a**hole!”
Comments
Powered by Facebook Comments
I’m curious what client feature forced you to do this – I’ve had to do similarly bad things with code in SalesForce; but in this case they might have intentionally tried to force you to use the value, not the label in your code as it is less likely to change. In VisualForce you could use outputField to show the label instead of the Value, but I’m sure for some reason you had to access the label in Apex itself (which is weird!).
This is an excellent idea – i voted on this on the idea exchange – maybe other can vote on it as well to get it released as soon as possible
http://ideas.salesforce.com/article/show/43022/The_ability_to_use_a_picklist_value_in_a_formula_field_without_ISPICKVAL
I could not agree more emphatically.
The client wants to do data entry via a picklist and then concatenate the picklists into a full mailing address. I use workflow to put this concatenated address into the standard Address fields on Contact.
I could use VF, but then would have to override the Edit screen and that is not worth it maintenance-wise.
Amen Steve. This has pi$$ed me off to no end over the last year. It’s funny how once you run into this use case (concatenating picklist values in a formula for example) it seems to come up over and over again. I can’t believe they have not solved this yet.
I fully agree. This has annoyed me for a long time. I voted on the idea referenced by Peter Martin a while ago. With 7500+ votes, you’d think that this would be on SFC’s “Ideas Under Consideration” list.
Hi Steve, I am guessing that this is a rhetorical question, but if you are interested in the backstory here, Eric B does a good job explaining it his 05-30-2008 comment in the Idea post. Your use case is pretty interesting – selecting addresses from picklists is not something I’ve seen other customers do. Is the goal speed of data entry or is it data quality? If it is data quality, this might be a good use of VLOOKUP() in a validation rule to validation the parts of the address, rather than deconstructing and reconstructing the standard address fields.
As to Michael’s point about the Idea not being classified as “Ideas Under Consideration”, that is just an oversight on my part, since we have already delivered one aspect of that Idea (picklists in validation rules), and hence it is definitely under consideration. I just updated it. My team is actively working on adding better picklist support in Formula Fields, which is the pain point that is highlighted here (and that I myself have felt). I am looking forward to the day I can mark that Idea as “delivered”.
Yes, thoroughly rhetorical!
Mostly I was just in a bad mood…
I know it’s coming, since we saw it on validation rules. Thanks for continuing to work on it–the validation rule implementation is awesome.
The use case is interesting. The client wants to parse addresses for use in door-to-door activities. Do create effective walk-lists, the street number, name, and direction all need to be parsed out. So I’m giving them some parsed address fields that I’m then combining back into the OtherAddress fields.
[...] gokubi.com « Are you really going to make we write this? [...]
I agree with this fully. It disgusts me to have to replicate picklist values word for word in another location to perform this function. This is simply a maintenance nightmare. People never remember to update the formula and there are always inconsistencies. TEXT() needs to work for more than just validation rules and workflows.
Have you ever considered doing this in an Apex trigger instead? At least in Apex you can just access the value directly.
I am so in agreement here. Heaven forbid you update the picklist. You just created 4 years worth of work!