You need to sign in to do that
Don't have an account?

Metadata API for adding picklist values to a particular record type
I am adding picklist values in Selected Values through Metadata API for a particular recordtype. but the existing selected values are removing when i assign new values to Selected values.
how to get the existing values from RecordTypePicklistValue[] in Metadata API or else only those two new values to be added in the Selected Values.
Code:
MetadataService.RecordType rt = new MetadataService.RecordType();
rt.active = true;
rt.fullName = 'Lead.Marketing';
rt.label = 'Marketing';
// Add pick list values
metadataservice.PicklistValue two = new metadataservice.PicklistValue();
two.fullName= 'second';
two.default_x=false;
metadataservice.PicklistValue three = new metadataservice.PicklistValue();
three.fullName= 'third';
three.default_x=false;
MetadataService.RecordTypePicklistValue ohmVersions = new MetadataService.RecordTypePicklistValue();
ohmVersions.Picklist = 'Picklist__C';
ohmVersions.values = new MetadataService.PicklistValue[] { two,three};
rt.PicklistValues = new MetadataService.RecordTypePicklistValue[] { ohmVersions };
return handleSaveResults( service.updateMetadata( new MetadataService.Metadata[] { rt })[0]);
Thanks,
Krish
how to get the existing values from RecordTypePicklistValue[] in Metadata API or else only those two new values to be added in the Selected Values.
Code:
MetadataService.RecordType rt = new MetadataService.RecordType();
rt.active = true;
rt.fullName = 'Lead.Marketing';
rt.label = 'Marketing';
// Add pick list values
metadataservice.PicklistValue two = new metadataservice.PicklistValue();
two.fullName= 'second';
two.default_x=false;
metadataservice.PicklistValue three = new metadataservice.PicklistValue();
three.fullName= 'third';
three.default_x=false;
MetadataService.RecordTypePicklistValue ohmVersions = new MetadataService.RecordTypePicklistValue();
ohmVersions.Picklist = 'Picklist__C';
ohmVersions.values = new MetadataService.PicklistValue[] { two,three};
rt.PicklistValues = new MetadataService.RecordTypePicklistValue[] { ohmVersions };
return handleSaveResults( service.updateMetadata( new MetadataService.Metadata[] { rt })[0]);
Thanks,
Krish
The Metadata Picklist.picklistValues (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_picklist.htm) represents the complete state of the values for the object in question. You will need to pass through any existing values you want to keep in addition to any new values.

Hey Daniel, would you please give an example as to how to query and automatically pass the existing picklistvalues into the class so that they can be updated?

Is there a way to setup a RecordType so that all values added to the picklist are added to that RecordType list of available values also?