function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hari G SHari G S 

Dynamic value update

Hi,

 

Can i add a new value to a pickList field.

 

eg: I have a field say Status. One value is there Open. When i call the trigger i want to add one more value say Closed.

 

When i try to update the existing value gets replaced.

 

Thanks

Hari G S

 

dcarmen66dcarmen66

Hi - I'm not exactly sure what you're asking. Is this a multi-select picklist so you want to have both Open and Closed in the status? Otherwise if you're updating the value then the previous value will always get replaced.

ashish raiashish rai

Hello,

May be this will help you to come accross with your problem. Please go through these link: 

http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_picklist.htm

http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2

public void setPicklistValues() {
  // Create a picklist
  Picklist expenseStatus = new Picklist();
  PicklistValue unsubmitted = new PicklistValue();
  unsubmitted.setFullName("Unsubmitted");
  PicklistValue submitted = new PicklistValue();
  submitted.setFullName("Submitted");
  PicklistValue approved = new PicklistValue();
  approved.setFullName("Approved");
  PicklistValue rejected = new PicklistValue();
  rejected.setFullName("Rejected");
  expenseStatus.setPicklistValues(new PicklistValue[]
      {unsubmitted, submitted, approved, rejected});
  
  CustomField expenseStatusField = new CustomField();
  expenseStatusField.setFullName(
      "ExpenseReport__c.ExpenseStatus__c");
  expenseStatusField.setLabel("Expense Report Status");
  expenseStatusField.setType(FieldType.Picklist);
  expenseStatusField.setPicklist(expenseStatus);
  try {
    AsyncResult[] ars =
    metadataConnection.create(new Metadata[] {expenseStatusField});
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }