You need to sign in to do that
Don't have an account?
AncaComaneciu
Metadata API error while updating Picklist values: WebService returned a SOAP Fault: Must specify a type attribute value for the metadata element
I am using the apex-mdapi MetadataService class to update the picklist values from Apex. However i keep getting teh following error on the update (List<MetadataService.SaveResult> lstResults = service.updateMetadata( new MetadataService.Metadata[] { customField });), not on read:
WebService returned a SOAP Fault: Must specify a type attribute value for the metadata element
The code i used is the one from below:
WebService returned a SOAP Fault: Must specify a type attribute value for the metadata element
The code i used is the one from below:
String picklistapiname = 'Lead.Status__c'; MetadataService.MetadataPort service = new MetadataService.MetadataPort(); service.SessionHeader = new MetadataService.SessionHeader_element(); service.SessionHeader.sessionId = UserInfo.getSessionId(); MetadataService.CustomField customField = (MetadataService.CustomField) service.readMetadata('CustomField', new String[] { picklistapiname}).getRecords()[0]; // For each on: customField > Get valueset > Get valueSetDefinition > get values for(MetadataService.CustomValue objCustomValue : customField.valueSet.valueSetDefinition.value){ if(objCustomValue.fullName == 'Closed'){ // API Name objCustomValue.fullName = 'Close'; // New API Value objCustomValue.label = 'Close'; // New Label value } } // Update List<MetadataService.SaveResult> lstResults = service.updateMetadata( new MetadataService.Metadata[] { customField }); for (MetadataService.SaveResult objResult : lstResults) { if (objResult.success) { System.debug('Successfully updated'); } else { if(objResult.errors.size() > 0){ System.debug('eror : ' + objResult.errors[0].message); } } }I also updated the CustomField class to include
public String type = 'CustomField'; public String fullName; private String[] fullName_type_info = new String[]{'fullName',SOAP_M_URI,null,'0','1','false'};Can someone please help? Thank you.