• Mark Liu 13
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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