I'm doing some client work where values selected from certain picklists will need to be sent to an SAP web service. I used WSDL2Apex to auto-generate classes.
The restricted-value fields typically either require a digit or a four-letter code. In the UI though we want this to be friendlier, however Salesforce doesn't really support key-value picklists.
So for a mock example, suppose one field for the web service is called CANDYTYPE, and the options are: CHEW (Chewy candy) STCK (Sticky candy) CNCH (Crunchy candy)
I'd rather have the descriptive names in the UI but I need to send the 4-letter codes to the web service. Ideally my Apex code that packages the data into a web service request should not have to scan for the string "Sticky candy" because maybe my client will decide to rename the picklist value to "Gummy candy" instead.
Ideas that have occurred to me so far:
- Use a custom setting or custom metadata type to store the mappings, so that at least if a client needs a picklist value edited we only have to edit two things without deploying new Apex code.
- Compromise by setting the picklist values to "CHEW - Chewy Candy", "STCK - Sticky Candy" etc so that I can just take a substring of the picklist values.
- Enable translations so that the picklist values can be CHEW, STCK, CNCH but the labels displayed are descriptive. I'm a little wary of this option as it has other consequences that could disrupt work we've already done for the client.
Any other ideas?