I am trying to update the record type to move the picklist values to the 'active values' . I am using the metadata api. Below is my code where Scope_Of_Services_Tasks__c is the name of object , Meeting_Type__c is the field name and Project_Management is the name of the Record type :-
MetadataService.RecordType rt = new MetadataService.RecordType();
rt.active = true;
rt.fullName = 'Project_Management';
rt.label = 'Project Management';
MetadataService.PicklistValue pv = new MetadataService.PicklistValue();
pv.fullName = 'test123';
MetadataService.RecordTypePicklistValue ohmVersions = new MetadataService.RecordTypePicklistValue();
ohmVersions.Picklist = 'Meeting_Type__c';
ohmVersions.values = new MetadataService.PicklistValue[] { pv };
rt.PicklistValues = new MetadataService.RecordTypePicklistValue[] { ohmVersions };
return handleSaveResults(
service.updateMetadata(
new MetadataService.Metadata[] { rt })[0]);
The code is giving this error :- "Web service callout failed: WebService returned a SOAP Fault: '' is not valid for type xsd:boolean, should be '0', '1', 'true' or 'false' faultcode=soapenv:Client faultactor="
PLease help me out as this is very urgent and I am trying since more than 2 days. Thanks
Update:- pv.fullName = 'test123'; here 'test123' is the picklist value that need to be moved to the active values in the record type picklist.
Best Answer
Here is your issue
I'm presuming you are using the Apex wrapper to the metadata API as found here
service.updateMetadata(..)
method, you first need to use thereadMetaData(..)
method for the metadata object you intend to update. In your case, this is theMetadataService.RecordType
MetadataService
wrapper classes that represent theMetaDataService.RecordType
and its child object collectionsupdateMetaData(..)
A close relevant example provided in class
MetadataServiceExamples
is methodupdatePicklist()
where you can see thereadMetaData(..)
call preceding theupdateMetadata()
call.