1

I have a field on the Case object with five values.

Severity__c

  1. Severity 1
  2. Severity 2
  3. Severity 3
  4. Severity 4
  5. Exempt

I use this field to dynamically display the fields in several different pages for picklists exactly as it is based on record type.

On one lightning component, however, I need to change the first value to display as "Severity 1 (System Down)" but when the user selects it, I need it to populate the field with the normal "Severity 1" value with out the extra (System Down) info.

I have no idea if this is even possible. I was thinking possibly create a static set of labels/values that would somehow load back into the Severity__c field.

1

If you have only one picklist value that needs to be update in that way you could create a SelectOption List. That way you can make the label anything you want and the value can stay what you need it to be. Below is just an example code at to how you can just create one selectoption with the different label while to others are the same.

Schema.DescribeFieldResult F = Account.Industry.getDescribe();
    List<Schema.PicklistEntry> P = F.getPicklistValues();
    List<SelectOption> SOList = new List<SelectOption>();
    for(Schema.PicklistEntry PE: P){
        if(PE.getValue() == 'Severity 1')
            SOList.add(new SelectOption(PE.getValue(), 'Severity 1 (System Down)'));
        else
            SOList.add(new SelectOption(PE.getValue(), PE.getValue()));
    }
0

One Approach could be:

  1. create a custom metadata object with the picklist value and the display value From the init of the lightning component query the custom metadata and show the display value in UI.
  2. When user selects a value and tries to save the data send the picklist value to back-end and save the information.
  3. Next time if you need to show the same picklist value in UI from lightning component based on the user value show its corresponding display value in UI
  4. This way you can add any number of picklist values,display values and it can be scaled up using metadata.

The only flip side to this approach is you need to maintain the picklist values in 2 places, on the field and other in metadata.

As of now i dont think metadata supports global picklist so we cannot re-use the same picklist in 2 places.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.