You need to sign in to do that
Don't have an account?
D-Price
Update Custom Picklist on Account using API
I am trying to update (add a value to) a custom picklist that is on our Account. I'm getting confused by Enterprise route and the Metadata route.
This post seems close, but I don't want to rename a field just to add a new value:
Here's the code I'm working with using an Enterprise connection:
public void updatePicklistSample(EnterpriseConnection connection) { try { DescribeSObjectResult describeSObjectResult = connection.describeSObject("Account"); Field[] fields = describeSObjectResult.getFields(); // create a map of all fields for later lookup Map<String, Field> fieldMap = new HashMap<>(); for(Field field : fields) fieldMap.put(field.getName(), field); for(Field field : fields) { // check whether this is my picklist if(field.getName().equals("My_Custom_Picklist__c")) { ArrayList<PicklistEntry> pickListValuesArrayList = new ArrayList<>(); for(PicklistEntry picklistEntry : field.getPicklistValues()) pickListValuesArrayList.add(picklistEntry); final PicklistEntry entry = new PicklistEntry(); entry.setActive(true); entry.setDefaultValue(false); entry.setValue("9999"); entry.setLabel("9999"); pickListValuesArrayList.add(entry); final PicklistEntry[] plv = pickListValuesArrayList.toArray(new PicklistEntry[pickListValuesArrayList.size()]); field.setPicklistValues(plv); } } // What to update here? connection.update(????); } catch(ConnectionException ce) { fail("Connection failed: " + ce); } }
I'm just not sure what SObject I need to update.
I've also seen this sample that creates a new picklist, but I just want to update a custom field on Account:
Does anyone have a clear example on how to do this? Any suggestions?
Thanks,
Derek